hyperttp 0.5.0 → 0.5.1

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/README.md CHANGED
@@ -1,6 +1,6 @@
1
- # Hyperttp ⚡
1
+ # Hyperttp
2
2
 
3
- **HTTP without boilerplate.**
3
+ **An Axios-like HTTP client with built-in request policies for modern TypeScript applications.**
4
4
 
5
5
  > English | [Русский](https://github.com/dirold2/hyperttp/tree/main/lang/ru)
6
6
 
@@ -9,244 +9,485 @@
9
9
  [![license](https://img.shields.io/npm/l/hyperttp)](./LICENSE)
10
10
  [![typescript](https://img.shields.io/badge/TypeScript-strict-blue)](https://www.typescriptlang.org/)
11
11
 
12
- An HTTP client for **Node.js**, **Bun**, **Deno**, and the **Browser** that provides retries,
13
- caching, rate limiting, metrics, parsing, serialization, and interceptors **out of the box**.
12
+ Hyperttp keeps familiar `get`, `post`, `put`, `patch`, and `delete` methods while adding response
13
+ parsing, caching, in-flight deduplication, rate limiting, concurrency queues, and interceptors
14
+ through one client.
14
15
 
15
16
  ```ts
16
17
  import { HyperClient } from "hyperttp";
17
18
 
18
- const client = new HyperClient();
19
+ const http = new HyperClient({
20
+ baseURL: "https://api.example.com",
21
+ });
19
22
 
20
- // Parse JSON explicitly, regardless of the response Content-Type
21
- const user = await client.request("https://api.example.com/users/1").json().send();
23
+ const users = await http.get<User[]>("/users");
22
24
 
23
- console.log(user);
25
+ console.log(users);
24
26
  ```
25
27
 
26
- No manual setup.
27
- No unnecessary code.
28
- Just make requests.
28
+ Shortcuts return parsed data directly. No `response.data` step is required.
29
29
 
30
- ---
30
+ ## Why Hyperttp?
31
31
 
32
- ## What is Hyperttp?
32
+ A real API client often grows beyond `fetch()` or a basic request wrapper:
33
33
 
34
- Most HTTP clients solve one problem:
34
+ ```text
35
+ HTTP request
36
+ ├── serialization and parsing
37
+ ├── caching
38
+ ├── duplicate request prevention
39
+ ├── rate limiting
40
+ ├── concurrency control
41
+ ├── cancellation and timeouts
42
+ └── interceptors
43
+ ```
35
44
 
36
- > "Send an HTTP request."
45
+ Hyperttp provides these policies through one composable client. It is most useful for SDKs,
46
+ backend services, bots, CLI tools, API integrations, and applications that would otherwise build
47
+ and maintain this infrastructure themselves.
37
48
 
38
- But real applications need much more:
49
+ Hyperttp is not universally better than every HTTP client. If you only need a small Fetch wrapper,
50
+ Ky or ofetch may be a better fit. For a Node-only client with HTTP/2 and pagination, Got is more
51
+ specialized. See [Choosing a client](#choosing-a-client) for an objective comparison.
39
52
 
40
- - retries
41
- - rate limiting
42
- - caching
43
- - request deduplication
44
- - parsing
45
- - serialization
46
- - metrics
47
- - interceptors
48
- - request queues
49
- - timeouts
53
+ ## Installation
50
54
 
51
- With most libraries, this turns into installing many additional packages and building your own wrappers.
55
+ ```bash
56
+ npm install hyperttp
57
+ ```
52
58
 
53
- Hyperttp provides these capabilities through a single client.
59
+ ```bash
60
+ pnpm add hyperttp
61
+ ```
54
62
 
55
- ---
63
+ ```bash
64
+ bun add hyperttp
65
+ ```
56
66
 
57
- ## Why Hyperttp?
67
+ ```bash
68
+ deno add npm:hyperttp
69
+ ```
58
70
 
59
- Instead of building your own networking layer:
71
+ ## Quick start
60
72
 
61
- ```text
62
- fetch
63
- ├── retry
64
- ├── cache
65
- ├── parser
66
- ├── metrics
67
- ├── serializer
68
- ├── queue
69
- ├── timeout
70
- └── custom wrappers
73
+ ### Create a reusable client
71
74
 
75
+ ```ts
76
+ import { HyperClient } from "hyperttp";
77
+
78
+ export const api = new HyperClient({
79
+ baseURL: "https://api.example.com/v1/",
80
+ });
72
81
  ```
73
82
 
74
- Hyperttp provides a ready-to-use infrastructure:
83
+ Reuse the client across your application so transports, connection pools, cache entries, and
84
+ plugin state can be shared.
75
85
 
76
- ```text
77
- Hyperttp
78
- ├── Retry
79
- ├── Cache
80
- ├── Metrics
81
- ├── Parser
82
- ├── Serializer
83
- ├── Queue
84
- ├── Interceptors
85
- ├── Timeout
86
- └── Rate Limiter
86
+ ```ts
87
+ interface User {
88
+ id: string;
89
+ name: string;
90
+ active: boolean;
91
+ }
92
+
93
+ const users = await api.get<User[]>("users");
94
+ const user = await api.get<User>("users/42");
95
+ ```
96
+
97
+ ### Send data
98
+
99
+ ```ts
100
+ const created = await api.post<User>("users", {
101
+ name: "Alice",
102
+ active: true,
103
+ });
104
+
105
+ await api.put("users/42", {
106
+ name: "Alice Cooper",
107
+ });
108
+
109
+ await api.patch("users/42", {
110
+ active: false,
111
+ });
112
+
113
+ await api.delete("users/42");
114
+ ```
115
+
116
+ Objects and arrays are serialized as JSON by the built-in serializer.
117
+
118
+ ## Request options
119
+
120
+ ### Query parameters
121
+
122
+ Hyperttp uses `query` where Axios uses `params`:
87
123
 
124
+ ```ts
125
+ const users = await api.get<User[]>("users", {
126
+ query: {
127
+ page: 1,
128
+ limit: 20,
129
+ active: true,
130
+ role: ["admin", "editor"],
131
+ },
132
+ });
88
133
  ```
89
134
 
90
- Create a client.
135
+ Array values become repeated query parameters. `null` and `undefined` values are omitted by the
136
+ fluent builder.
91
137
 
92
- Start making requests.
138
+ ### Headers
93
139
 
94
- ---
140
+ ```ts
141
+ const profile = await api.get<User>("profile", {
142
+ headers: {
143
+ Authorization: `Bearer ${token}`,
144
+ "X-Request-ID": requestId,
145
+ },
146
+ });
147
+ ```
95
148
 
96
- ## Quick Start
149
+ Hyperttp currently has no top-level default `headers` option. Use request options or a request
150
+ interceptor when headers must be added globally.
97
151
 
98
- ### 1. Install Hyperttp
152
+ ### Timeout and cancellation
99
153
 
100
- ```bash
101
- # Node.js
102
- npm install hyperttp
103
- pnpm add hyperttp
154
+ ```ts
155
+ const controller = new AbortController();
104
156
 
105
- # Bun
106
- bun add hyperttp
157
+ const request = api.get("reports/large", {
158
+ timeout: 10_000,
159
+ signal: controller.signal,
160
+ });
107
161
 
108
- # Deno
109
- deno add npm:hyperttp
162
+ controller.abort();
110
163
 
164
+ await request;
111
165
  ```
112
166
 
113
- ### 2. Basic Usage
167
+ Timeouts, aborts, and transport failures reject the request. HTTP error status codes are handled
168
+ differently; see [Responses and HTTP errors](#responses-and-http-errors).
169
+
170
+ ### Explicit response format
114
171
 
115
172
  ```ts
116
- import { HyperClient } from "hyperttp";
173
+ const text = await api.get<string>("health", "text");
117
174
 
118
- const client = new HyperClient({
119
- baseURL: "https://api.example.com",
175
+ const document = await api.get("document.xml", {
176
+ responseType: "xml",
120
177
  });
178
+ ```
179
+
180
+ Supported response hints are `json`, `text`, `xml`, `html`, `buffer`, and `stream`.
181
+
182
+ ## Understanding `baseURL`
183
+
184
+ Hyperttp resolves relative URLs with the standard `URL` rules:
121
185
 
122
- await client.get("/users"); // Parses based on Content-Type
123
- await client.request("/users").json().send();
124
- await client.request("/users").post().jsonBody({ name: "John" }).json().send();
125
- await client.request("/users/1").put().jsonBody({ name: "Alice" }).json().send();
126
- await client.delete("/users/1");
186
+ ```ts
187
+ const api = new HyperClient({
188
+ baseURL: "https://api.example.com/v1/",
189
+ });
190
+
191
+ await api.get("users"); // https://api.example.com/v1/users
192
+ await api.get("/users"); // https://api.example.com/users
127
193
  ```
128
194
 
129
- ---
195
+ A leading slash starts from the origin root. Omit it when the path should remain under the
196
+ `baseURL` pathname.
197
+
198
+ `baseURL` applies to HyperClient shortcuts, `head()`, `stream()`, and `RequestBuilder`. The directly
199
+ delegated `client.rest` namespace currently expects an absolute URL.
130
200
 
131
- ## Hyperttp vs Other HTTP Clients
201
+ ## Fluent requests
132
202
 
133
- | Feature | fetch | Axios | Ky | Hyperttp |
134
- | ------------------------ | ----- | ------ | ------- | -------- |
135
- | Promise API | ✅ | ✅ | ✅ | ✅ |
136
- | Retry | ❌ | Plugin | ✅ | ✅ |
137
- | Cache | ❌ | ❌ | ❌ | ✅ |
138
- | Metrics | ❌ | ❌ | ❌ | ✅ |
139
- | Rate Limiter | ❌ | ❌ | ❌ | ✅ |
140
- | Queue | ❌ | ❌ | ❌ | ✅ |
141
- | Parser | ❌ | ❌ | Partial | ✅ |
142
- | Serializer | ❌ | ❌ | ❌ | ✅ |
143
- | Interceptors | ❌ | ✅ | Hooks | ✅ |
144
- | Transport auto-detection | ❌ | ❌ | ❌ | ✅ |
203
+ Use shortcuts for simple requests and `RequestBuilder` when a longer request reads better as a
204
+ chain:
145
205
 
146
- ---
206
+ ```ts
207
+ const user = await api
208
+ .request("users")
209
+ .post()
210
+ .headers({
211
+ "X-Request-ID": requestId,
212
+ })
213
+ .query({ notify: true })
214
+ .jsonBody({
215
+ name: "Alice",
216
+ active: true,
217
+ })
218
+ .json()
219
+ .send<User>();
220
+ ```
147
221
 
148
- ## Who is Hyperttp for?
222
+ Available builder methods include:
149
223
 
150
- Perfect for:
224
+ - HTTP method: `get`, `post`, `put`, `patch`, `delete`, `head`, `options`, `method`
225
+ - Request data: `headers`, `query`, `body`, `jsonBody`
226
+ - Control: `timeout`, `signal`
227
+ - Response hint: `json`, `text`, `xml`, `html`, `buffer`, `stream`
228
+ - Utility: `clone`, `send`
151
229
 
152
- - REST APIs & SDKs
153
- - CLI applications & Discord bots
154
- - Backend & Serverless services
155
- - Web scraping
156
- - Enterprise applications
230
+ For live response streaming, use `client.stream()` rather than the builder response hint.
157
231
 
158
- ---
232
+ ## Responses and HTTP errors
159
233
 
160
- ## Advanced Configuration
234
+ ### Convenience methods return data
161
235
 
162
236
  ```ts
163
- const client = new HyperClient({
164
- baseURL: "https://api.example.com",
237
+ const users = await api.get<User[]>("users");
238
+ ```
165
239
 
166
- retry: {
167
- maxRetries: 3,
168
- },
240
+ The return value is already the parsed response data. Status, headers, and other envelope fields
241
+ are intentionally omitted from shortcut results.
169
242
 
170
- cache: {
171
- ttl: 60_000,
172
- },
243
+ ### Access the full response
173
244
 
174
- timeout: 30_000,
175
- });
245
+ Use the REST namespace when status and headers are needed:
246
+
247
+ ```ts
248
+ const response = await api.rest.get<User[]>("https://api.example.com/v1/users");
249
+
250
+ console.log(response.ok);
251
+ console.log(response.status);
252
+ console.log(response.headers);
253
+ console.log(response.data);
176
254
  ```
177
255
 
178
- ### Built-in Plugins
256
+ The full response contains `protocol`, `ok`, `status`, `statusText`, `headers`, `url`, `data`, and
257
+ optional metadata/raw fields.
179
258
 
180
- `HyperClient` automatically registers interceptors, serialization, metrics, request deduplication,
181
- caching, rate limiting, queueing, and response parsing.
259
+ ### HTTP statuses do not throw by default
182
260
 
183
- Disable only automatic response parsing:
261
+ A `4xx` or `5xx` response resolves normally. With shortcuts, the parsed error body is returned. With
262
+ the full response API, inspect `response.ok` or `response.status`:
184
263
 
185
264
  ```ts
186
- const client = new HyperClient({
187
- responseConverter: false,
265
+ const response = await api.rest.get<ErrorPayload>("https://api.example.com/v1/users/missing");
266
+
267
+ if (!response.ok) {
268
+ console.error(response.status, response.data);
269
+ }
270
+ ```
271
+
272
+ This differs from Axios, Ky, Got, and ofetch defaults, which commonly reject non-success responses.
273
+
274
+ ## Built-in request policies
275
+
276
+ Built-in plugins are registered automatically. Policies that should be explicit, such as rate
277
+ limiting and queueing, can be enabled in client configuration:
278
+
279
+ ```ts
280
+ const api = new HyperClient({
281
+ baseURL: "https://api.example.com/v1/",
282
+
283
+ cache: {
284
+ enabled: true,
285
+ ttl: 60_000,
286
+ maxSize: 1_000,
287
+ },
288
+
289
+ inflight: {
290
+ enabled: true,
291
+ },
292
+
293
+ rateLimit: {
294
+ enabled: true,
295
+ maxRequests: 100,
296
+ windowMs: 60_000,
297
+ },
298
+
299
+ queue: {
300
+ enabled: true,
301
+ maxConcurrent: 20,
302
+ },
188
303
  });
189
304
  ```
190
305
 
191
- Disable the entire built-in plugin set for a minimal pipeline:
306
+ | Policy | Purpose |
307
+ | ----------------------- | ------------------------------------------------------------- |
308
+ | Cache | Reuse successful GET/HEAD responses according to cache policy |
309
+ | In-flight deduplication | Share compatible concurrent GET requests |
310
+ | Rate limiter | Control request volume and react to server penalties |
311
+ | Queue | Limit concurrent work per configured partition |
312
+ | Serializer | Encode object/array request bodies |
313
+ | Parser | Convert JSON, text, HTML, XML, buffer, and empty responses |
314
+ | Interceptors | Transform requests and responses |
315
+
316
+ Disable the entire built-in plugin preset when composing a custom pipeline:
192
317
 
193
318
  ```ts
194
319
  const client = new HyperClient({
195
320
  builtInPlugins: false,
321
+ plugins: [myPlugin],
196
322
  });
197
323
  ```
198
324
 
199
- The REST protocol remains available when built-in plugins are disabled. Custom plugins supplied
200
- through `plugins` or registered with `client.use()` continue to work. When `builtInPlugins` is
201
- `false`, `responseConverter` has no effect because the built-in parser is not registered.
325
+ The REST protocol and plugins explicitly supplied through `plugins` or `client.use()` remain
326
+ available.
202
327
 
203
- ---
328
+ > Retry options exist in the current type surface, but retry execution is not documented as a
329
+ > stable feature in `0.5.x`. It is therefore not counted as an active capability in the comparison
330
+ > below.
204
331
 
205
- ## Architecture
332
+ ## Streaming
206
333
 
207
- ```text
208
- Application
209
- │
210
- ▼
211
- HyperClient
212
- │
213
- Plugin Pipeline
214
- │
215
- Transport (Auto-detected)
216
- │
217
- HTTP
334
+ `stream()` returns the complete response envelope. Its `data` is an async-iterable byte stream:
335
+
336
+ ```ts
337
+ const response = await api.stream("events");
338
+ const decoder = new TextDecoder();
218
339
 
340
+ for await (const chunk of response.data) {
341
+ console.log(decoder.decode(chunk, { stream: true }));
342
+ }
219
343
  ```
220
344
 
221
- All components are independent and replaceable.
345
+ The concrete stream implementation depends on the active runtime transport.
222
346
 
223
- ---
347
+ ## TypeScript
224
348
 
225
- ## Runtime Transports
349
+ Public request, response, client, and transport types are exported from the package root:
350
+
351
+ ```ts
352
+ import {
353
+ HyperClient,
354
+ type HyperClientOptions,
355
+ type RestRequestOptions,
356
+ type UniversalResponse,
357
+ } from "hyperttp";
358
+
359
+ interface User {
360
+ id: string;
361
+ name: string;
362
+ }
363
+
364
+ const options: RestRequestOptions = {
365
+ query: { active: true },
366
+ timeout: 5_000,
367
+ };
368
+
369
+ const users = await new HyperClient({
370
+ baseURL: "https://api.example.com",
371
+ }).get<User[]>("/users", options);
372
+ ```
226
373
 
227
- Hyperttp uses `@hyperttp/transport-undici` automatically on Node.js. The transport is included with
228
- the `hyperttp` package, so no additional installation or client configuration is required:
374
+ Generics describe the expected response shape; they do not validate untrusted server data at
375
+ runtime.
376
+
377
+ ## Lifecycle
378
+
379
+ A client may own connection pools and other transport resources. Destroy long-lived clients during
380
+ application shutdown, not after every request:
229
381
 
230
382
  ```ts
231
- import { HyperClient } from "hyperttp";
383
+ const api = new HyperClient({
384
+ baseURL: "https://api.example.com",
385
+ });
232
386
 
233
- const client = new HyperClient();
234
- // Uses UndiciTransport on Node.js.
387
+ try {
388
+ await runApplication(api);
389
+ } finally {
390
+ await api.destroy(true);
391
+ }
235
392
  ```
236
393
 
237
- Other runtimes can use the standard `globalThis.fetch` fallback. Runtime-specific transport packages
238
- can be installed separately when available:
394
+ Pass `true` for graceful shutdown or `false` when resources must be destroyed immediately.
395
+
396
+ ## Coming from Axios?
397
+
398
+ The request style is intentionally familiar, but Hyperttp is not a drop-in Axios replacement.
399
+
400
+ | Axios | Hyperttp |
401
+ | ------------------------------- | ------------------------------------------------------------- |
402
+ | `axios.create({ baseURL })` | `new HyperClient({ baseURL })` |
403
+ | `axios.get(url, { params })` | `client.get(url, { query })` |
404
+ | `axios.post(url, data, config)` | `client.post(url, body, options)` |
405
+ | `response.data` | Returned directly by shortcut methods |
406
+ | `response.status` | Use an absolute URL with `client.rest.*` |
407
+ | `signal` | `signal` in request options or the positional signal argument |
408
+ | Request/response interceptors | Built-in interceptor plugin or custom plugins |
409
+ | Instance default headers | Request options or an interceptor |
410
+
411
+ Legacy `Request` and `PreparedRequest` exports remain available for compatibility but are
412
+ deprecated. New code should use `client.request()` and `RequestBuilder`.
413
+
414
+ ## Choosing a client
415
+
416
+ The goal of this table is not to declare a universal winner. It highlights when each client is a
417
+ natural fit based on its documented built-in features.
418
+
419
+ | Capability | Fetch | Axios | Ky | ofetch | Got | Hyperttp |
420
+ | -------------------------- | --------------- | ------------------------- | ------------------------ | -------------------------- | -------------------------------- | ------------------------------ |
421
+ | Primary runtimes | Runtime native | Browser, Node | Browser, Node, Bun, Deno | Node, browser, workers | Node | Node plus Fetch-based runtimes |
422
+ | Parsed-data shortcut | No | Via `response.data` | Via `.json()` | Yes | JSON mode | Yes |
423
+ | Full response access | Yes | Yes | Yes | Yes (`.raw`) | Yes | Yes (`client.rest`) |
424
+ | Automatic retries | No | No built-in | Yes | Yes | Yes | Not currently stable |
425
+ | Application response cache | No | No built-in | No built-in | No built-in | Yes | Yes |
426
+ | In-flight deduplication | No | No built-in | No built-in | No built-in | No built-in | Yes |
427
+ | Built-in rate limiting | No | No | No | No | No | Yes |
428
+ | Built-in concurrency queue | No | No | No | No | No | Yes |
429
+ | Interceptors or hooks | No | Interceptors | Hooks | Interceptors | Hooks | Interceptors and plugins |
430
+ | Notable strength | Zero dependency | Ecosystem and familiarity | Small Fetch-based API | Universal Fetch experience | Node streams, HTTP/2, pagination | Integrated request policies |
431
+
432
+ ### Choose Fetch when
433
+
434
+ - you need no dependency;
435
+ - platform APIs are enough;
436
+ - you are comfortable composing policies yourself.
437
+
438
+ ### Choose Axios when
439
+
440
+ - your team already knows its API;
441
+ - its mature ecosystem matters more than built-in operational policies;
442
+ - browser and Node support are the main targets.
443
+
444
+ ### Choose Ky when
239
445
 
240
- | Runtime | Package | Availability |
241
- | ------- | ---------------------------- | ----------------------------------- |
242
- | Node.js | `@hyperttp/transport-undici` | Included and selected automatically |
243
- | Bun | `@hyperttp/transport-bun` | Optional runtime-specific transport |
244
- | Deno | `@hyperttp/transport-deno` | Optional runtime-specific transport |
446
+ - you want a small, modern Fetch wrapper;
447
+ - retries and lifecycle hooks cover your needs;
448
+ - a Fetch-compatible response model is desirable.
245
449
 
246
- ---
450
+ ### Choose ofetch when
451
+
452
+ - you want automatic parsing and retries with a Fetch-oriented universal API;
453
+ - Node, browser, and worker portability matters;
454
+ - you do not need cache, deduplication, rate limiting, and queueing in the client itself.
455
+
456
+ ### Choose Got when
457
+
458
+ - the application is Node-only;
459
+ - advanced streams, HTTP/2, pagination, timings, and RFC caching are important.
460
+
461
+ ### Choose Hyperttp when
462
+
463
+ - you want Axios-like request methods that return parsed data directly;
464
+ - cache, deduplication, rate limiting, and concurrency control should share one pipeline;
465
+ - the client is part of an SDK, service, bot, CLI, scraper, or integration with operational limits;
466
+ - you prefer one extensible client over several unrelated wrappers.
467
+
468
+ Comparison references: [Axios](https://github.com/axios/axios),
469
+ [Ky](https://github.com/sindresorhus/ky), [ofetch](https://github.com/unjs/ofetch), and
470
+ [Got](https://github.com/sindresorhus/got). Features and runtime support can change between releases;
471
+ verify the requirements that matter to your application.
472
+
473
+ Ky, Axios, ofetch, and Got are comparison references only. They are not Hyperttp dependencies.
474
+
475
+ ## Runtime transports
476
+
477
+ - Node.js resolves the included `@hyperttp/transport-undici` transport.
478
+ - Other runtimes can use the Fetch fallback when `globalThis.fetch` is available.
479
+ - Optional Bun- and Deno-specific transport packages may be installed separately.
480
+ - A custom transport can be passed to the constructor or through `customTransport`.
481
+
482
+ Use `await client.getTransportName()` to inspect the selected transport.
483
+
484
+ Runtime code paths target Node.js, Bun, Deno, and browsers. The repository test suite currently
485
+ verifies the Node.js path; validate the other runtimes in your own deployment environment.
247
486
 
248
487
  ## Ecosystem
249
488
 
489
+ Hyperttp is composed from focused packages:
490
+
250
491
  - `@hyperttp/core`
251
492
  - `@hyperttp/types`
252
493
  - `@hyperttp/interceptors`
@@ -259,19 +500,6 @@ can be installed separately when available:
259
500
  - `@hyperttp/parser`
260
501
  - `@hyperttp/transport-undici`
261
502
 
262
- ---
263
-
264
- ## Performance
265
-
266
- The benchmark suite compares complete client stacks rather than isolated request primitives. Results
267
- from a local environment are not a guarantee of production performance, so test with your own
268
- workload, concurrency, payloads, and network conditions.
269
-
270
- Benchmark sources and current results are available in
271
- [IT-IF-OR/bench](https://github.com/IT-IF-OR/bench).
272
-
273
- ---
274
-
275
503
  ## License
276
504
 
277
- MIT © dirold2
505
+ MIT
@@ -39,12 +39,15 @@ export interface UrlExtractorInterface {
39
39
  * @ru Извлекает идентификаторы из URL для указанной сущности и платформы.
40
40
  * @en Extracts IDs from URL for the specified entity and platform.
41
41
  *
42
- * @typeParam T - ID type (string or number).
43
42
  * @param url - URL to extract from.
44
43
  * @param entity - Entity name to look for.
45
44
  * @param platform - Platform name.
45
+ * @param castNumbers - Convert safe decimal values to numbers when explicitly enabled.
46
46
  * @returns Object with extracted IDs mapped by group names.
47
47
  */
48
- extractId<T extends string | number>(url: string, entity: string, platform: string): Record<string, T>;
48
+ extractId(url: string, entity: string, platform: string): Record<string, string>;
49
+ extractId(url: string, entity: string, platform: string, castNumbers: false): Record<string, string>;
50
+ extractId(url: string, entity: string, platform: string, castNumbers: true): Record<string, string | number>;
51
+ extractId(url: string, entity: string, platform: string, castNumbers: boolean): Record<string, string | number>;
49
52
  }
50
53
  //# sourceMappingURL=url-extractor.d.ts.map