hyperttp 0.2.0 → 0.2.2

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.
Files changed (49) hide show
  1. package/README.md +55 -65
  2. package/dist/Hyperttp/Core/CacheManager.d.ts +16 -3
  3. package/dist/Hyperttp/Core/CacheManager.d.ts.map +1 -1
  4. package/dist/Hyperttp/Core/CacheManager.js +45 -13
  5. package/dist/Hyperttp/Core/CacheManager.js.map +1 -1
  6. package/dist/Hyperttp/Core/HttpClientImproved.d.ts +5 -3
  7. package/dist/Hyperttp/Core/HttpClientImproved.d.ts.map +1 -1
  8. package/dist/Hyperttp/Core/HttpClientImproved.js +164 -157
  9. package/dist/Hyperttp/Core/HttpClientImproved.js.map +1 -1
  10. package/dist/Hyperttp/Core/MetricsManager.d.ts +32 -0
  11. package/dist/Hyperttp/Core/MetricsManager.d.ts.map +1 -0
  12. package/dist/Hyperttp/Core/MetricsManager.js +96 -0
  13. package/dist/Hyperttp/Core/MetricsManager.js.map +1 -0
  14. package/dist/Hyperttp/Core/QueueManager.d.ts.map +1 -1
  15. package/dist/Hyperttp/Core/QueueManager.js +12 -5
  16. package/dist/Hyperttp/Core/QueueManager.js.map +1 -1
  17. package/dist/Hyperttp/Core/RateLimiter.d.ts +6 -36
  18. package/dist/Hyperttp/Core/RateLimiter.d.ts.map +1 -1
  19. package/dist/Hyperttp/Core/RateLimiter.js +41 -58
  20. package/dist/Hyperttp/Core/RateLimiter.js.map +1 -1
  21. package/dist/Hyperttp/Core/RequestBuilder.d.ts +17 -4
  22. package/dist/Hyperttp/Core/RequestBuilder.d.ts.map +1 -1
  23. package/dist/Hyperttp/Core/RequestBuilder.js +41 -18
  24. package/dist/Hyperttp/Core/RequestBuilder.js.map +1 -1
  25. package/dist/Hyperttp/Core/index.d.ts +4 -1
  26. package/dist/Hyperttp/Core/index.d.ts.map +1 -1
  27. package/dist/Hyperttp/Core/index.js +11 -5
  28. package/dist/Hyperttp/Core/index.js.map +1 -1
  29. package/dist/Hyperttp/Request.d.ts +5 -0
  30. package/dist/Hyperttp/Request.d.ts.map +1 -1
  31. package/dist/Hyperttp/Request.js +17 -35
  32. package/dist/Hyperttp/Request.js.map +1 -1
  33. package/dist/Hyperttp/UrlExtractor.d.ts +1 -1
  34. package/dist/Hyperttp/UrlExtractor.d.ts.map +1 -1
  35. package/dist/Hyperttp/UrlExtractor.js.map +1 -1
  36. package/dist/Hyperttp/index.d.ts +3 -1
  37. package/dist/Hyperttp/index.d.ts.map +1 -1
  38. package/dist/Hyperttp/index.js +6 -1
  39. package/dist/Hyperttp/index.js.map +1 -1
  40. package/dist/Types/index.d.ts +45 -206
  41. package/dist/Types/index.d.ts.map +1 -1
  42. package/dist/Types/index.js +7 -16
  43. package/dist/Types/index.js.map +1 -1
  44. package/dist/Types/request.d.ts +15 -100
  45. package/dist/Types/request.d.ts.map +1 -1
  46. package/dist/Types/request.js.map +1 -1
  47. package/dist/index.d.ts.map +1 -1
  48. package/dist/index.js.map +1 -1
  49. package/package.json +1 -1
@@ -1,281 +1,91 @@
1
- import { RateLimiterConfig } from "../Hyperttp/Core";
2
- import { ResponseType } from "./request";
3
- /**
4
- * Interface for a universal URL extractor
5
- */
6
- export interface UrlExtractorInterface {
7
- /**
8
- * Register a platform with its URL patterns
9
- * @param platform Platform name (e.g., "yandex", "spotify")
10
- * @param patterns Array of URL patterns for the platform
11
- */
12
- registerPlatform(platform: string, patterns: UrlPattern[]): void;
13
- /**
14
- * Extract an entity ID or related info from a URL
15
- * @param url URL to extract from
16
- * @param entity Entity type ("track", "album", "artist", "playlist", etc.)
17
- * @param platform Platform name that has been registered
18
- * @returns Record of extracted values (keys depend on the pattern)
19
- */
20
- extractId<T extends string | number>(url: string, entity: string, platform: string): Record<string, T>;
21
- }
22
- /**
23
- * Defines a URL extraction pattern for a platform
24
- */
25
- export interface UrlPattern<T extends string = string> {
26
- /** Entity type this pattern applies to (track, album, artist, playlist, etc.) */
27
- entity: string;
28
- /** Regex with named capturing groups to extract IDs or info */
29
- regex: RegExp;
30
- /** Names of the capturing groups to extract */
31
- groupNames: T[];
32
- }
1
+ import { ResponseType, RequestInterface } from "./request";
2
+ export * from "./request";
33
3
  /**
34
- * Base error class for HTTP client operations.
35
- * Contains additional context about the failed request including status code, URL, and method.
4
+ * Базовый класс ошибки
36
5
  */
37
6
  export declare class HttpClientError extends Error {
7
+ code: string;
38
8
  statusCode?: number | undefined;
39
9
  originalError?: Error | undefined;
40
10
  url?: string | undefined;
41
11
  method?: string | undefined;
42
- constructor(message: string, statusCode?: number | undefined, originalError?: Error | undefined, url?: string | undefined, method?: string | undefined);
12
+ constructor(message: string, code?: string, statusCode?: number | undefined, originalError?: Error | undefined, url?: string | undefined, method?: string | undefined);
43
13
  }
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
14
  export declare class TimeoutError extends HttpClientError {
49
15
  constructor(url: string, timeout: number);
50
16
  }
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
17
  export declare class RateLimitError extends HttpClientError {
56
18
  retryAfter?: number | undefined;
57
19
  constructor(url: string, retryAfter?: number | undefined);
58
20
  }
59
- /**
60
- * Log level for HTTP client logging.
61
- * Defines the verbosity of log output from the client.
62
- */
63
21
  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
22
  export interface RetryOptions {
78
- /** Maximum number of retry attempts before giving up */
79
23
  maxRetries: number;
80
- /** Base delay in milliseconds between retry attempts (exponential backoff) */
81
24
  baseDelay: number;
82
- /** Maximum delay in milliseconds between retry attempts */
83
25
  maxDelay: number;
84
- /** HTTP status codes that should trigger a retry */
85
26
  retryStatusCodes: number[];
86
- /** Whether to add random jitter to retry delays to prevent thundering herd */
87
27
  jitter: boolean;
88
28
  }
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
29
  export type RequestInterceptor = (config: {
97
30
  url: string;
98
31
  method: string;
99
32
  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
- */
33
+ body?: any;
34
+ }) => Promise<any> | any;
114
35
  export type ResponseInterceptor = (response: {
115
36
  status: number;
116
37
  headers: Record<string, any>;
117
38
  body: Buffer;
118
39
  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
- */
40
+ }) => Promise<any> | any;
129
41
  export interface HttpClientOptions {
130
- /** Request timeout in milliseconds (default: 15000) */
131
42
  timeout?: number;
132
- /** Maximum number of concurrent requests (default: 50) */
133
43
  maxConcurrent?: number;
134
- /** Maximum number of retry attempts for failed requests (default: 3) */
135
44
  maxRetries?: number;
136
- /** Cache time-to-live in milliseconds (default: 300000) */
137
45
  cacheTTL?: number;
138
- /** Maximum number of cached entries (default: 500) */
139
46
  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") */
47
+ rateLimit?: {
48
+ maxRequests: number;
49
+ windowMs: number;
50
+ };
143
51
  userAgent?: string;
144
- /** Custom logger function for HTTP client events */
145
- logger?: LoggerFunction;
146
- /** Retry behavior configuration */
52
+ logger?: (level: LogLevel, message: string, meta?: any) => void;
147
53
  retryOptions?: Partial<RetryOptions>;
148
- /** Whether to automatically follow HTTP redirects (default: true) */
149
54
  followRedirects?: boolean;
150
- /** Maximum number of redirects to follow (default: 5) */
151
55
  maxRedirects?: number;
152
- /** Maximum response size in bytes (default: 1MB) */
153
56
  maxResponseBytes?: number;
154
- /** Function to validate HTTP status codes (default: 200-299) */
155
57
  validateStatus?: (status: number) => boolean;
156
- /** HTTP methods that should be cached (default: ["GET", "HEAD"]) */
157
58
  cacheMethods?: string[];
158
- /** Maximum number of request metrics to store (default: 10000) */
159
59
  maxMetricsSize?: number;
160
- /** Whether to enable verbose logging (default: false) */
161
60
  verbose?: boolean;
162
- /** Whether to enable request queuing (default: true) */
163
61
  enableQueue?: boolean;
164
- /** Whether to enable rate limiting (default: true) */
165
62
  enableRateLimit?: boolean;
166
- /** Whether to enable caching (default: true) */
167
63
  enableCache?: boolean;
168
64
  }
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
65
  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
66
  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
67
  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
68
  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
69
  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
- */
70
+ patch<T = any>(req: RequestInterface | string, body?: any, responseType?: ResponseType): Promise<T>;
244
71
  head(req: RequestInterface | string): Promise<{
245
72
  status: number;
246
73
  headers: Record<string, any>;
247
74
  }>;
248
- /**
249
- * Clears the internal cache of the HTTP client
250
- */
75
+ stream(req: RequestInterface | string): Promise<StreamResponse>;
251
76
  clearCache(): void;
252
77
  }
253
- /**
254
- * Metrics collected for HTTP requests to monitor performance and behavior.
255
- * Contains timing information, response details, and caching information.
256
- */
257
78
  export interface RequestMetrics {
258
- /** Timestamp when the request started */
259
79
  startTime: number;
260
- /** Timestamp when the request completed */
261
80
  endTime: number;
262
- /** Total duration of the request in milliseconds */
263
81
  duration: number;
264
- /** HTTP status code of the response (if available) */
265
82
  statusCode?: number;
266
- /** Number of bytes received in the response */
267
83
  bytesReceived: number;
268
- /** Number of bytes sent in the request body */
269
84
  bytesSent: number;
270
- /** Number of retry attempts made for this request */
271
85
  retries: number;
272
- /** Whether the response was served from cache */
273
86
  cached: boolean;
274
- /** URL of the request */
275
87
  url: string;
276
- /** HTTP method used (GET, POST, etc.) */
277
88
  method: string;
278
- /** Hash of the request body for cache key generation */
279
89
  bodyHash?: string;
280
90
  }
281
91
  export interface StreamResponse {
@@ -284,5 +94,34 @@ export interface StreamResponse {
284
94
  body: AsyncIterable<Uint8Array>;
285
95
  url: string;
286
96
  }
287
- export * from "./request";
97
+ /**
98
+ * Interface for a universal URL extractor
99
+ */
100
+ export interface UrlExtractorInterface {
101
+ /**
102
+ * Register a platform with its URL patterns
103
+ * @param platform Platform name (e.g., "yandex", "spotify")
104
+ * @param patterns Array of URL patterns for the platform
105
+ */
106
+ registerPlatform(platform: string, patterns: UrlPattern[]): void;
107
+ /**
108
+ * Extract an entity ID or related info from a URL
109
+ * @param url URL to extract from
110
+ * @param entity Entity type ("track", "album", "artist", "playlist", etc.)
111
+ * @param platform Platform name that has been registered
112
+ * @returns Record of extracted values (keys depend on the pattern)
113
+ */
114
+ extractId<T extends string | number>(url: string, entity: string, platform: string): Record<string, T>;
115
+ }
116
+ /**
117
+ * Defines a URL extraction pattern for a platform
118
+ */
119
+ export interface UrlPattern<T extends string = string> {
120
+ /** Entity type this pattern applies to (track, album, artist, playlist, etc.) */
121
+ entity: string;
122
+ /** Regex with named capturing groups to extract IDs or info */
123
+ regex: RegExp;
124
+ /** Names of the capturing groups to extract */
125
+ groupNames: T[];
126
+ }
288
127
  //# sourceMappingURL=index.d.ts.map
@@ -1 +1 @@
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,MAAM,YAAA,EACZ,MAAM,CAAC,EAAE,MAAM,YAAA;CAMzB;AAED;;;GAGG;AACH,qBAAa,YAAa,SAAQ,eAAe;gBACnC,GAAG,EAAE,MAAM,EAAE,OAAO,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AS,EAAE,MAAM,CAAC;IAClB,OAAO,EAAE,MAAM,CAAC;IAChB,MAAM,EAAE,OAAO,CAAC;IAChB,GAAG,EAAE,MAAM,CAAC;IACZ,MAAM,EAAE,MAAM,CAAC;IACf,QAAQ,CAAC,EAAE,MAAM,CAAC;CACnB;AAED,MAAM,WAAW,cAAc;IAC7B,MAAM,EAAE,MAAM,CAAC;IACf,OAAO,EAAE,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC,CAAC;IAC7B,IAAI,EAAE,aAAa,CAAC,UAAU,CAAC,CAAC;IAChC,GAAG,EAAE,MAAM,CAAC;CACb;AAED;;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"}
@@ -15,17 +15,19 @@ var __exportStar = (this && this.__exportStar) || function(m, exports) {
15
15
  };
16
16
  Object.defineProperty(exports, "__esModule", { value: true });
17
17
  exports.RateLimitError = exports.TimeoutError = exports.HttpClientError = void 0;
18
+ __exportStar(require("./request"), exports);
18
19
  /**
19
- * Base error class for HTTP client operations.
20
- * Contains additional context about the failed request including status code, URL, and method.
20
+ * Базовый класс ошибки
21
21
  */
22
22
  class HttpClientError extends Error {
23
+ code;
23
24
  statusCode;
24
25
  originalError;
25
26
  url;
26
27
  method;
27
- constructor(message, statusCode, originalError, url, method) {
28
+ constructor(message, code = "HTTP_ERROR", statusCode, originalError, url, method) {
28
29
  super(message);
30
+ this.code = code;
29
31
  this.statusCode = statusCode;
30
32
  this.originalError = originalError;
31
33
  this.url = url;
@@ -35,31 +37,20 @@ class HttpClientError extends Error {
35
37
  }
36
38
  }
37
39
  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
40
  class TimeoutError extends HttpClientError {
43
41
  constructor(url, timeout) {
44
- super(`Request timeout after ${timeout}ms for ${url}`);
42
+ super(`Request timeout after ${timeout}ms for ${url}`, "TIMEOUT", 408, undefined, url);
45
43
  this.name = "TimeoutError";
46
- Object.setPrototypeOf(this, TimeoutError.prototype);
47
44
  }
48
45
  }
49
46
  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
47
  class RateLimitError extends HttpClientError {
55
48
  retryAfter;
56
49
  constructor(url, retryAfter) {
57
- super(`Rate limited for ${url}${retryAfter ? `, retry after ${retryAfter}ms` : ""}`);
50
+ super(`Rate limited for ${url}${retryAfter ? `, retry after ${retryAfter}ms` : ""}`, "RATE_LIMIT", 429, undefined, url);
58
51
  this.retryAfter = retryAfter;
59
52
  this.name = "RateLimitError";
60
- Object.setPrototypeOf(this, RateLimitError.prototype);
61
53
  }
62
54
  }
63
55
  exports.RateLimitError = RateLimitError;
64
- __exportStar(require("./request"), exports);
65
56
  //# sourceMappingURL=index.js.map
@@ -1 +1 @@
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,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Y,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;QAC9B,MAAM,CAAC,cAAc,CAAC,IAAI,EAAE,eAAe,CAAC,SAAS,CAAC,CAAC;IACzD,CAAC;CACF;AAbD,0CAaC;AAED,MAAa,YAAa,SAAQ,eAAe;IAC/C,YAAY,GAAW,EAAE,OAAe;QACtC,KAAK,CACH,yBAAyB,OAAO,UAAU,GAAG,EAAE,EAC/C,SAAS,EACT,GAAG,EACH,SAAS,EACT,GAAG,CACJ,CAAC;QACF,IAAI,CAAC,IAAI,GAAG,cAAc,CAAC;IAC7B,CAAC;CACF;AAXD,oCAWC;AAED,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,EAC7E,YAAY,EACZ,GAAG,EACH,SAAS,EACT,GAAG,CACJ,CAAC;QARK,eAAU,GAAV,UAAU,CAAS;QAS1B,IAAI,CAAC,IAAI,GAAG,gBAAgB,CAAC;IAC/B,CAAC;CACF;AAdD,wCAcC"}
@@ -1,136 +1,51 @@
1
1
  /**
2
2
  * Represents HTTP request headers
3
3
  */
4
- export type RequestHeaders = {
5
- [key: string]: string;
6
- };
4
+ export type RequestHeaders = Record<string, string>;
7
5
  /**
8
6
  * Represents URL query parameters
9
7
  */
10
- export type RequestQuery = {
11
- [key: string]: string;
12
- };
8
+ export type RequestQuery = Record<string, string | number | boolean | undefined | null>;
13
9
  /**
14
- * Represents body data for requests
10
+ * Исправлено: Body теперь может быть любым объектом, строкой или Buffer.
15
11
  */
16
- export type RequestBodyData = {
17
- [key: string]: string;
18
- };
12
+ export type RequestBodyData = any | null | undefined;
19
13
  /**
20
- * Configuration for a request
14
+ * Конфигурация для создания запроса
21
15
  */
22
16
  export type RequestConfig = {
23
- /** Protocol scheme (http or https) */
24
17
  scheme: string;
25
- /** Hostname or IP address */
26
18
  host: string;
27
- /** Port number */
28
19
  port: number;
29
- /** Optional path after host */
30
20
  path?: string;
31
- /** Optional headers */
32
21
  headers?: RequestHeaders;
33
- /** Optional query parameters */
34
22
  query?: RequestQuery;
35
- /** Optional body data */
36
23
  bodyData?: RequestBodyData;
37
24
  };
25
+ export type Method = "GET" | "POST" | "PUT" | "DELETE" | "PATCH" | "HEAD";
38
26
  /**
39
- * HTTP method type
40
- */
41
- export type Method = "get" | "post";
42
- /**
43
- * Represents a generic object response
44
- */
45
- export type ObjectResponse = {
46
- [key: string]: any;
47
- };
48
- /**
49
- * Represents a plain string response
50
- */
51
- export type StringResponse = string;
52
- /**
53
- * Represents either an object or string response
54
- */
55
- export type Response = ObjectResponse | StringResponse;
56
- /**
57
- * Interface for a request object
27
+ * Основной интерфейс запроса.
28
+ * Сеттеры помечены как необязательные (?), чтобы простые объекты-заглушки
29
+ * в HttpClient соответствовали этому интерфейсу.
58
30
  */
59
31
  export interface RequestInterface {
60
- /** Set the request path */
32
+ getURL(): string;
33
+ getHeaders(): RequestHeaders;
34
+ getBodyData(): RequestBodyData;
61
35
  setPath?(path: string): RequestInterface;
62
- /** Set the host for the request */
63
36
  setHost?(host: string): RequestInterface;
64
- /** Get current request headers */
65
- getHeaders?(): RequestHeaders;
66
- /** Replace all headers */
67
37
  setHeaders?(headers: RequestHeaders): RequestInterface;
68
- /** Add headers to the existing ones */
69
38
  addHeaders?(headers: RequestHeaders): RequestInterface;
70
- /** Get current query parameters */
71
39
  getQuery?(): RequestQuery;
72
- /** Replace all query parameters */
73
40
  setQuery?(query: RequestQuery): RequestInterface;
74
- /** Add query parameters */
75
41
  addQuery?(query: RequestQuery): RequestInterface;
76
- /** Get query string representation */
77
42
  getQueryAsString?(): string;
78
- /** Get request body data */
79
- getBodyData?(): RequestBodyData;
80
- /** Get body data as string (e.g., for JSON or URL-encoded) */
81
43
  getBodyDataString?(): string;
82
- /** Replace body data */
83
44
  setBodyData?(bodyData: RequestBodyData): RequestInterface;
84
- /** Add data to the existing body */
85
45
  addBodyData?(bodyData: RequestBodyData): RequestInterface;
86
- /** Get URI (path + query) */
87
46
  getURI?(): string;
88
- /** Get full URL including scheme, host, port, path and query */
89
- getURL?(): string;
90
- }
91
- /**
92
- * Interface for a HTTP client
93
- */
94
- export interface HttpClientInterface {
95
- /**
96
- * Send a GET request
97
- * @param request Request object
98
- * @returns Response object or string
99
- */
100
- get(request: RequestInterface): Promise<Response>;
101
- /**
102
- * Send a POST request
103
- * @param request Request object
104
- * @returns Response object or string
105
- */
106
- post(request: RequestInterface): Promise<Response>;
107
- }
108
- /**
109
- * Options to configure HttpClient
110
- */
111
- export interface HttpClientOptions {
112
- /** Maximum number of concurrent requests */
113
- maxConcurrent?: number;
114
- /** Rate limiting options */
115
- rateLimit?: {
116
- maxRequests?: number;
117
- windowMs?: number;
118
- };
119
- /** Maximum number of retry attempts */
120
- maxRetries?: number;
121
- /** Cache time-to-live in milliseconds */
122
- cacheTTL?: number;
123
- /** Maximum number of cached items */
124
- cacheMaxSize?: number;
125
- /** Logger function to capture debug/info/warn/error messages */
126
- logger?: (level: "debug" | "info" | "warn" | "error", msg: string, meta?: any) => void;
127
- /** User-Agent string to send with requests */
128
- userAgent?: string;
129
- /** Follow HTTP redirects (default true) */
130
- followRedirects?: boolean;
131
- /** Request timeout in milliseconds */
132
- timeout?: number;
133
- responseType?: ResponseType;
47
+ setSignal?(signal: AbortSignal): RequestInterface;
48
+ getSignal?(): AbortSignal | undefined;
134
49
  }
135
- export type ResponseType = "json" | "text" | "buffer" | "xml" | "stream";
50
+ export type ResponseType = "json" | "text" | "buffer" | "xml" | "stream" | "auto";
136
51
  //# sourceMappingURL=request.d.ts.map
@@ -1 +1 @@
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;IAC1B,sCAAsC;IACtC,MAAM,EAAE,MAAM,CAAC;IAEf,6BAA6B;IAC7B,IAAI,EAAE,MAAM,CAAC;IAEb,kBAAkB;IAClB,IAAI,EAAE,MAAM,CAAC;IAEb,+BAA+B;IAC/B,IAAI,CAAC,EAAE,MAAM,CAAC;IAEd,uBAAuB;IACvB,OAAO,CAAC,EAAE,cAAc,CAAC;IAEzB,gCAAgC;IAChC,KAAK,CAAC,EAAE,YAAY,CAAC;IAErB,yBAAyB;IACzB,QAAQ,CAAC,EAAE,eAAe,CAAC;CAC5B,CAAC;AAEF;;GAEG;AACH,MAAM,MAAM,MAAM,GAAG,KAAK,GAAG,MAAM,CAAC;AAEpC;;GAEG;AACH,MAAM,MAAM,cAAc,GAAG;IAAE,CAAC,GAAG,EAAE,MAAM,GAAG,GAAG,CAAA;CAAE,CAAC;AAEpD;;GAEG;AACH,MAAM,MAAM,cAAc,GAAG,MAAM,CAAC;AAEpC;;GAEG;AACH,MAAM,MAAM,QAAQ,GAAG,cAAc,GAAG,cAAc,CAAC;AAEvD;;GAEG;AACH,MAAM,WAAW,gBAAgB;IAC/B,2BAA2B;IAC3B,OAAO,CAA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vC;AAED,MAAM,MAAM,YAAY,GACpB,MAAM,GACN,MAAM,GACN,QAAQ,GACR,KAAK,GACL,QAAQ,GACR,MAAM,CAAC"}
@@ -1 +1 @@
1
- {"version":3,"file":"request.js","sourceRoot":"","sources":["../../../src/Types/request.ts"],"names":[],"mappings":""}
1
+ {"version":3,"file":"request.js","sourceRoot":"","sources":["../../src/Types/request.ts"],"names":[],"mappings":""}
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,kBAAkB,EAClB,cAAc,EACd,YAAY,EACZ,YAAY,EACZ,WAAW,EACX,OAAO,EACP,eAAe,EACf,YAAY,GACb,MAAM,qBAAqB,CAAC;AAE7B,mBAAmB,kBAAkB,CAAC;AACtC,mBAAmB,oBAAoB,CAAC"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,kBAAkB,EAClB,cAAc,EACd,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.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":";;;AAAA,gDAS6B;AAR3B,8GAAA,kBAAkB,OAAA;AAClB,0GAAA,cAAc,OAAA;AACd,wGAAA,YAAY,OAAA;AACZ,wGAAA,YAAY,OAAA;AACZ,uGAAA,WAAW,OAAA;AACX,mGAAA,OAAO,OAAA;AACP,2GAAA,eAAe,OAAA;AACf,wGAAA,YAAY,OAAA"}
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":";;;AAAA,gDAS6B;AAR3B,8GAAA,kBAAkB,OAAA;AAClB,0GAAA,cAAc,OAAA;AACd,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.2.0",
3
+ "version": "0.2.2",
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",