@raymondfox/ts-toolbox 1.0.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +60 -0
- package/dist/http/HttpClient.d.ts +75 -0
- package/dist/http/HttpClient.d.ts.map +1 -0
- package/dist/http/HttpClient.js +237 -0
- package/dist/http/HttpClient.js.map +1 -0
- package/dist/http/index.d.ts +4 -0
- package/dist/http/index.d.ts.map +1 -0
- package/dist/http/index.js +9 -0
- package/dist/http/index.js.map +1 -0
- package/dist/http/types.d.ts +78 -0
- package/dist/http/types.d.ts.map +1 -0
- package/dist/http/types.js +23 -0
- package/dist/http/types.js.map +1 -0
- package/dist/index.d.ts +6 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +24 -0
- package/dist/index.js.map +1 -0
- package/dist/logger/Logger.d.ts +62 -0
- package/dist/logger/Logger.d.ts.map +1 -0
- package/dist/logger/Logger.js +120 -0
- package/dist/logger/Logger.js.map +1 -0
- package/dist/logger/formatters/JsonFormatter.d.ts +14 -0
- package/dist/logger/formatters/JsonFormatter.d.ts.map +1 -0
- package/dist/logger/formatters/JsonFormatter.js +27 -0
- package/dist/logger/formatters/JsonFormatter.js.map +1 -0
- package/dist/logger/formatters/LoggerFormatter.d.ts +21 -0
- package/dist/logger/formatters/LoggerFormatter.d.ts.map +1 -0
- package/dist/logger/formatters/LoggerFormatter.js +3 -0
- package/dist/logger/formatters/LoggerFormatter.js.map +1 -0
- package/dist/logger/formatters/PrettyFormatter.d.ts +26 -0
- package/dist/logger/formatters/PrettyFormatter.d.ts.map +1 -0
- package/dist/logger/formatters/PrettyFormatter.js +72 -0
- package/dist/logger/formatters/PrettyFormatter.js.map +1 -0
- package/dist/logger/formatters/index.d.ts +5 -0
- package/dist/logger/formatters/index.d.ts.map +1 -0
- package/dist/logger/formatters/index.js +8 -0
- package/dist/logger/formatters/index.js.map +1 -0
- package/dist/logger/index.d.ts +19 -0
- package/dist/logger/index.d.ts.map +1 -0
- package/dist/logger/index.js +40 -0
- package/dist/logger/index.js.map +1 -0
- package/dist/logger/transports/BufferedTransport.d.ts +71 -0
- package/dist/logger/transports/BufferedTransport.d.ts.map +1 -0
- package/dist/logger/transports/BufferedTransport.js +111 -0
- package/dist/logger/transports/BufferedTransport.js.map +1 -0
- package/dist/logger/transports/ConsoleTransport.d.ts +26 -0
- package/dist/logger/transports/ConsoleTransport.d.ts.map +1 -0
- package/dist/logger/transports/ConsoleTransport.js +39 -0
- package/dist/logger/transports/ConsoleTransport.js.map +1 -0
- package/dist/logger/transports/DiscordTransport.d.ts +48 -0
- package/dist/logger/transports/DiscordTransport.d.ts.map +1 -0
- package/dist/logger/transports/DiscordTransport.js +96 -0
- package/dist/logger/transports/DiscordTransport.js.map +1 -0
- package/dist/logger/transports/FileTransport.d.ts +104 -0
- package/dist/logger/transports/FileTransport.d.ts.map +1 -0
- package/dist/logger/transports/FileTransport.js +251 -0
- package/dist/logger/transports/FileTransport.js.map +1 -0
- package/dist/logger/transports/HttpTransport.d.ts +47 -0
- package/dist/logger/transports/HttpTransport.d.ts.map +1 -0
- package/dist/logger/transports/HttpTransport.js +57 -0
- package/dist/logger/transports/HttpTransport.js.map +1 -0
- package/dist/logger/transports/LoggerTransport.d.ts +52 -0
- package/dist/logger/transports/LoggerTransport.d.ts.map +1 -0
- package/dist/logger/transports/LoggerTransport.js +33 -0
- package/dist/logger/transports/LoggerTransport.js.map +1 -0
- package/dist/logger/transports/index.d.ts +13 -0
- package/dist/logger/transports/index.d.ts.map +1 -0
- package/dist/logger/transports/index.js +16 -0
- package/dist/logger/transports/index.js.map +1 -0
- package/dist/logger/types/LogLevel.d.ts +17 -0
- package/dist/logger/types/LogLevel.d.ts.map +1 -0
- package/dist/logger/types/LogLevel.js +23 -0
- package/dist/logger/types/LogLevel.js.map +1 -0
- package/dist/logger/types/LogMessage.d.ts +19 -0
- package/dist/logger/types/LogMessage.d.ts.map +1 -0
- package/dist/logger/types/LogMessage.js +3 -0
- package/dist/logger/types/LogMessage.js.map +1 -0
- package/dist/logger/types/LoggerOptions.d.ts +17 -0
- package/dist/logger/types/LoggerOptions.d.ts.map +1 -0
- package/dist/logger/types/LoggerOptions.js +3 -0
- package/dist/logger/types/LoggerOptions.js.map +1 -0
- package/dist/logger/types/index.d.ts +4 -0
- package/dist/logger/types/index.d.ts.map +1 -0
- package/dist/logger/types/index.js +18 -0
- package/dist/logger/types/index.js.map +1 -0
- package/dist/retry/index.d.ts +3 -0
- package/dist/retry/index.d.ts.map +1 -0
- package/dist/retry/index.js +6 -0
- package/dist/retry/index.js.map +1 -0
- package/dist/retry/retry.d.ts +38 -0
- package/dist/retry/retry.d.ts.map +1 -0
- package/dist/retry/retry.js +117 -0
- package/dist/retry/retry.js.map +1 -0
- package/dist/retry/types.d.ts +65 -0
- package/dist/retry/types.d.ts.map +1 -0
- package/dist/retry/types.js +3 -0
- package/dist/retry/types.js.map +1 -0
- package/dist/socket/browserSocket/BrowserSocketClient.d.ts +82 -0
- package/dist/socket/browserSocket/BrowserSocketClient.d.ts.map +1 -0
- package/dist/socket/browserSocket/BrowserSocketClient.js +345 -0
- package/dist/socket/browserSocket/BrowserSocketClient.js.map +1 -0
- package/dist/socket/browserSocket/index.d.ts +2 -0
- package/dist/socket/browserSocket/index.d.ts.map +1 -0
- package/dist/socket/browserSocket/index.js +6 -0
- package/dist/socket/browserSocket/index.js.map +1 -0
- package/dist/socket/index.d.ts +6 -0
- package/dist/socket/index.d.ts.map +1 -0
- package/dist/socket/index.js +15 -0
- package/dist/socket/index.js.map +1 -0
- package/dist/socket/nodeSocket/NodeSocketClient.d.ts +70 -0
- package/dist/socket/nodeSocket/NodeSocketClient.d.ts.map +1 -0
- package/dist/socket/nodeSocket/NodeSocketClient.js +357 -0
- package/dist/socket/nodeSocket/NodeSocketClient.js.map +1 -0
- package/dist/socket/nodeSocket/NodeSocketServer.d.ts +101 -0
- package/dist/socket/nodeSocket/NodeSocketServer.d.ts.map +1 -0
- package/dist/socket/nodeSocket/NodeSocketServer.js +472 -0
- package/dist/socket/nodeSocket/NodeSocketServer.js.map +1 -0
- package/dist/socket/nodeSocket/index.d.ts +4 -0
- package/dist/socket/nodeSocket/index.d.ts.map +1 -0
- package/dist/socket/nodeSocket/index.js +8 -0
- package/dist/socket/nodeSocket/index.js.map +1 -0
- package/dist/socket/shared/ConnectionState.d.ts +5 -0
- package/dist/socket/shared/ConnectionState.d.ts.map +1 -0
- package/dist/socket/shared/ConnectionState.js +3 -0
- package/dist/socket/shared/ConnectionState.js.map +1 -0
- package/dist/socket/shared/Socket.d.ts +34 -0
- package/dist/socket/shared/Socket.d.ts.map +1 -0
- package/dist/socket/shared/Socket.js +83 -0
- package/dist/socket/shared/Socket.js.map +1 -0
- package/dist/socket/shared/SocketEvent.d.ts +8 -0
- package/dist/socket/shared/SocketEvent.d.ts.map +1 -0
- package/dist/socket/shared/SocketEvent.js +3 -0
- package/dist/socket/shared/SocketEvent.js.map +1 -0
- package/dist/socket/shared/SocketMessage.d.ts +25 -0
- package/dist/socket/shared/SocketMessage.d.ts.map +1 -0
- package/dist/socket/shared/SocketMessage.js +3 -0
- package/dist/socket/shared/SocketMessage.js.map +1 -0
- package/dist/socket/shared/SocketMiddleware.d.ts +15 -0
- package/dist/socket/shared/SocketMiddleware.d.ts.map +1 -0
- package/dist/socket/shared/SocketMiddleware.js +27 -0
- package/dist/socket/shared/SocketMiddleware.js.map +1 -0
- package/dist/socket/shared/SocketOptions.d.ts +47 -0
- package/dist/socket/shared/SocketOptions.d.ts.map +1 -0
- package/dist/socket/shared/SocketOptions.js +3 -0
- package/dist/socket/shared/SocketOptions.js.map +1 -0
- package/dist/socket/shared/SocketSerializer.d.ts +16 -0
- package/dist/socket/shared/SocketSerializer.d.ts.map +1 -0
- package/dist/socket/shared/SocketSerializer.js +16 -0
- package/dist/socket/shared/SocketSerializer.js.map +1 -0
- package/dist/socket/shared/SocketValidation.d.ts +10 -0
- package/dist/socket/shared/SocketValidation.d.ts.map +1 -0
- package/dist/socket/shared/SocketValidation.js +3 -0
- package/dist/socket/shared/SocketValidation.js.map +1 -0
- package/dist/socket/shared/TypedSocket.d.ts +48 -0
- package/dist/socket/shared/TypedSocket.d.ts.map +1 -0
- package/dist/socket/shared/TypedSocket.js +3 -0
- package/dist/socket/shared/TypedSocket.js.map +1 -0
- package/dist/socket/shared/index.d.ts +12 -0
- package/dist/socket/shared/index.d.ts.map +1 -0
- package/dist/socket/shared/index.js +10 -0
- package/dist/socket/shared/index.js.map +1 -0
- package/dist/timeout/index.d.ts +4 -0
- package/dist/timeout/index.d.ts.map +1 -0
- package/dist/timeout/index.js +9 -0
- package/dist/timeout/index.js.map +1 -0
- package/dist/timeout/timeout.d.ts +39 -0
- package/dist/timeout/timeout.d.ts.map +1 -0
- package/dist/timeout/timeout.js +68 -0
- package/dist/timeout/timeout.js.map +1 -0
- package/dist/timeout/types.d.ts +30 -0
- package/dist/timeout/types.d.ts.map +1 -0
- package/dist/timeout/types.js +17 -0
- package/dist/timeout/types.js.map +1 -0
- package/package.json +79 -0
- package/readme.md +928 -0
package/CHANGELOG.md
ADDED
|
@@ -0,0 +1,60 @@
|
|
|
1
|
+
# Changelog
|
|
2
|
+
|
|
3
|
+
All notable changes to this project will be documented in this file.
|
|
4
|
+
|
|
5
|
+
The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
|
|
6
|
+
and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
|
|
7
|
+
|
|
8
|
+
---
|
|
9
|
+
|
|
10
|
+
## [1.0.0] — 2026-10-01
|
|
11
|
+
|
|
12
|
+
### Added
|
|
13
|
+
|
|
14
|
+
#### Logger
|
|
15
|
+
- Structured, transport-based logging system
|
|
16
|
+
- Log levels: `TRACE`, `DEBUG`, `INFO`, `SUCCESS`, `WARN`, `ERROR`, `FATAL`
|
|
17
|
+
- Scoped loggers with nested scope support
|
|
18
|
+
- Per-transport log level filtering
|
|
19
|
+
- `ConsoleTransport` — colorized terminal output via `PrettyFormatter`
|
|
20
|
+
- `FileTransport` — NDJSON append to disk
|
|
21
|
+
- `HttpTransport` — HTTP POST with timeout
|
|
22
|
+
- `DiscordTransport` — Discord webhook with rich embeds
|
|
23
|
+
- `PrettyFormatter` — ANSI colors, icons and context pretty-printing
|
|
24
|
+
- `JsonFormatter` — compact JSON strings for log aggregation pipelines
|
|
25
|
+
- Custom formatter and transport APIs
|
|
26
|
+
|
|
27
|
+
#### Socket
|
|
28
|
+
- Event-based WebSocket communication layer
|
|
29
|
+
- `NodeSocketServer` — Node.js WebSocket server
|
|
30
|
+
- `NodeSocketClient` — Node.js WebSocket client
|
|
31
|
+
- `BrowserSocketClient` — Browser-compatible WebSocket client
|
|
32
|
+
- Event subscription, unsubscription and emission
|
|
33
|
+
- Broadcast support
|
|
34
|
+
|
|
35
|
+
#### Retry
|
|
36
|
+
- `retry()` — retries any async/sync operation on failure
|
|
37
|
+
- Strategies: `fixed`, `linear`, `exponential`, custom `BackoffStrategy`
|
|
38
|
+
- Configurable delay, max delay, jitter
|
|
39
|
+
- `retryIf` predicate for conditional retries
|
|
40
|
+
- `onRetry` callback for logging/telemetry
|
|
41
|
+
- `AbortSignal` support for cancellation
|
|
42
|
+
|
|
43
|
+
#### Timeout
|
|
44
|
+
- `withTimeout()` — races a promise against a timer
|
|
45
|
+
- `wrapWithTimeout()` — wraps an async function with a timeout
|
|
46
|
+
- `TimeoutError` — typed error with the elapsed `ms`
|
|
47
|
+
- `AbortController` integration for cancelling the underlying operation
|
|
48
|
+
- Custom error messages (string or factory function)
|
|
49
|
+
|
|
50
|
+
#### HTTP
|
|
51
|
+
- `HttpClient` — strongly-typed fetch wrapper
|
|
52
|
+
- Shorthand methods: `get`, `post`, `put`, `patch`, `delete`, `head`
|
|
53
|
+
- Generic typed responses: `HttpResponse<T>`
|
|
54
|
+
- `HttpError` — typed error with `status` and `statusText`
|
|
55
|
+
- Request / response / error interceptors
|
|
56
|
+
- Automatic JSON serialization and deserialization
|
|
57
|
+
- Query parameter handling
|
|
58
|
+
- Per-request and client-level timeout (via `withTimeout`)
|
|
59
|
+
- Per-request and client-level retry (via `retry`)
|
|
60
|
+
- `createHttpClient()` convenience factory
|
|
@@ -0,0 +1,75 @@
|
|
|
1
|
+
import { type HttpClientOptions, type HttpRequestConfig, type HttpResponse, type RequestInterceptor, type ResponseInterceptor, type ErrorInterceptor } from './types';
|
|
2
|
+
/**
|
|
3
|
+
* A lightweight, strongly-typed HTTP client built on the native `fetch` API.
|
|
4
|
+
*
|
|
5
|
+
* Features:
|
|
6
|
+
* - Typed responses via generics
|
|
7
|
+
* - Base URL + default headers
|
|
8
|
+
* - Per-request and client-level timeout (integrates with `withTimeout`)
|
|
9
|
+
* - Per-request and client-level retry (integrates with `retry`)
|
|
10
|
+
* - Request / response / error interceptors
|
|
11
|
+
* - Automatic JSON serialization / deserialization
|
|
12
|
+
* - Query parameter handling
|
|
13
|
+
*
|
|
14
|
+
* @example Basic usage
|
|
15
|
+
* ```ts
|
|
16
|
+
* const http = new HttpClient({ baseUrl: 'https://api.example.com' });
|
|
17
|
+
*
|
|
18
|
+
* const response = await http.get<User>('/users/1');
|
|
19
|
+
* console.log(response.data);
|
|
20
|
+
* ```
|
|
21
|
+
*
|
|
22
|
+
* @example With retry + timeout
|
|
23
|
+
* ```ts
|
|
24
|
+
* const http = new HttpClient({
|
|
25
|
+
* baseUrl: 'https://api.example.com',
|
|
26
|
+
* timeout: 5_000,
|
|
27
|
+
* retry: { retries: 3, backoff: 'exponential', delay: 500 },
|
|
28
|
+
* });
|
|
29
|
+
* ```
|
|
30
|
+
*
|
|
31
|
+
* @example With interceptors
|
|
32
|
+
* ```ts
|
|
33
|
+
* http.interceptors.request.use((config) => {
|
|
34
|
+
* config.headers['Authorization'] = `Bearer ${getToken()}`;
|
|
35
|
+
* return config;
|
|
36
|
+
* });
|
|
37
|
+
*
|
|
38
|
+
* http.interceptors.response.use((res) => {
|
|
39
|
+
* logger.info(`← ${res.status} ${res.raw.url}`);
|
|
40
|
+
* return res;
|
|
41
|
+
* });
|
|
42
|
+
* ```
|
|
43
|
+
*/
|
|
44
|
+
export declare class HttpClient {
|
|
45
|
+
private readonly options;
|
|
46
|
+
readonly interceptors: {
|
|
47
|
+
request: RequestInterceptor[];
|
|
48
|
+
response: ResponseInterceptor[];
|
|
49
|
+
error: ErrorInterceptor[];
|
|
50
|
+
};
|
|
51
|
+
constructor(options?: HttpClientOptions);
|
|
52
|
+
/** Add a request interceptor. Returns `this` for chaining. */
|
|
53
|
+
useRequestInterceptor(interceptor: RequestInterceptor): this;
|
|
54
|
+
/** Add a response interceptor. Returns `this` for chaining. */
|
|
55
|
+
useResponseInterceptor(interceptor: ResponseInterceptor): this;
|
|
56
|
+
/** Add an error interceptor. Returns `this` for chaining. */
|
|
57
|
+
useErrorInterceptor(interceptor: ErrorInterceptor): this;
|
|
58
|
+
get<T = unknown>(url: string, config?: Omit<HttpRequestConfig, 'method' | 'body'>): Promise<HttpResponse<T>>;
|
|
59
|
+
post<T = unknown>(url: string, body?: unknown, config?: Omit<HttpRequestConfig, 'method' | 'body'>): Promise<HttpResponse<T>>;
|
|
60
|
+
put<T = unknown>(url: string, body?: unknown, config?: Omit<HttpRequestConfig, 'method' | 'body'>): Promise<HttpResponse<T>>;
|
|
61
|
+
patch<T = unknown>(url: string, body?: unknown, config?: Omit<HttpRequestConfig, 'method' | 'body'>): Promise<HttpResponse<T>>;
|
|
62
|
+
delete<T = unknown>(url: string, config?: Omit<HttpRequestConfig, 'method' | 'body'>): Promise<HttpResponse<T>>;
|
|
63
|
+
head(url: string, config?: Omit<HttpRequestConfig, 'method' | 'body'>): Promise<HttpResponse<void>>;
|
|
64
|
+
request<T = unknown>(path: string, config?: HttpRequestConfig): Promise<HttpResponse<T>>;
|
|
65
|
+
}
|
|
66
|
+
/**
|
|
67
|
+
* Creates a pre-configured {@link HttpClient} instance.
|
|
68
|
+
*
|
|
69
|
+
* @example
|
|
70
|
+
* ```ts
|
|
71
|
+
* const http = createHttpClient({ baseUrl: 'https://api.example.com', timeout: 5_000 });
|
|
72
|
+
* ```
|
|
73
|
+
*/
|
|
74
|
+
export declare function createHttpClient(options?: HttpClientOptions): HttpClient;
|
|
75
|
+
//# sourceMappingURL=HttpClient.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"HttpClient.d.ts","sourceRoot":"","sources":["../../src/http/HttpClient.ts"],"names":[],"mappings":"AAIA,OAAO,EAEH,KAAK,iBAAiB,EAEtB,KAAK,iBAAiB,EACtB,KAAK,YAAY,EACjB,KAAK,kBAAkB,EACvB,KAAK,mBAAmB,EACxB,KAAK,gBAAgB,EACxB,MAAM,SAAS,CAAC;AAiDjB;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAyCG;AACH,qBAAa,UAAU;IACnB,OAAO,CAAC,QAAQ,CAAC,OAAO,CAA8B;IAEtD,QAAQ,CAAC,YAAY;QACjB,OAAO,EAAS,kBAAkB,EAAE;QACpC,QAAQ,EAAQ,mBAAmB,EAAE;QACrC,KAAK,EAAW,gBAAgB,EAAE;MACpC;IAEF,YAAY,OAAO,GAAE,iBAAsB,EAO1C;IAID,8DAA8D;IAC9D,qBAAqB,CAAC,WAAW,EAAE,kBAAkB,GAAG,IAAI,CAG3D;IAED,+DAA+D;IAC/D,sBAAsB,CAAC,WAAW,EAAE,mBAAmB,GAAG,IAAI,CAG7D;IAED,6DAA6D;IAC7D,mBAAmB,CAAC,WAAW,EAAE,gBAAgB,GAAG,IAAI,CAGvD;IAID,GAAG,CAAC,CAAC,GAAG,OAAO,EAAE,GAAG,EAAE,MAAM,EAAE,MAAM,CAAC,EAAE,IAAI,CAAC,iBAAiB,EAAE,QAAQ,GAAG,MAAM,CAAC,GAAG,OAAO,CAAC,YAAY,CAAC,CAAC,CAAC,CAAC,CAE3G;IAED,IAAI,CAAC,CAAC,GAAG,OAAO,EAAE,GAAG,EAAE,MAAM,EAAE,IAAI,CAAC,EAAE,OAAO,E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Property(exports, "__esModule", { value: true });
|
|
3
|
+
exports.HttpClient = void 0;
|
|
4
|
+
exports.createHttpClient = createHttpClient;
|
|
5
|
+
const retry_1 = require("../retry/retry");
|
|
6
|
+
const timeout_1 = require("../timeout/timeout");
|
|
7
|
+
const types_1 = require("../timeout/types");
|
|
8
|
+
const types_2 = require("./types");
|
|
9
|
+
// ─── Helpers ──────────────────────────────────────────────────────────────────
|
|
10
|
+
function buildUrl(base, path, params) {
|
|
11
|
+
const url = base ? new URL(path, base.endsWith('/') ? base : base + '/') : new URL(path);
|
|
12
|
+
if (params) {
|
|
13
|
+
for (const [key, value] of Object.entries(params)) {
|
|
14
|
+
if (value != null) {
|
|
15
|
+
url.searchParams.set(key, String(value));
|
|
16
|
+
}
|
|
17
|
+
}
|
|
18
|
+
}
|
|
19
|
+
return url.toString();
|
|
20
|
+
}
|
|
21
|
+
function mergeHeaders(...sources) {
|
|
22
|
+
return Object.assign({}, ...sources.filter(Boolean));
|
|
23
|
+
}
|
|
24
|
+
async function parseBody(response) {
|
|
25
|
+
const contentType = response.headers.get('content-type') ?? '';
|
|
26
|
+
if (contentType.includes('application/json')) {
|
|
27
|
+
return response.json();
|
|
28
|
+
}
|
|
29
|
+
return response.text();
|
|
30
|
+
}
|
|
31
|
+
// ─── HttpClient ───────────────────────────────────────────────────────────────
|
|
32
|
+
/**
|
|
33
|
+
* A lightweight, strongly-typed HTTP client built on the native `fetch` API.
|
|
34
|
+
*
|
|
35
|
+
* Features:
|
|
36
|
+
* - Typed responses via generics
|
|
37
|
+
* - Base URL + default headers
|
|
38
|
+
* - Per-request and client-level timeout (integrates with `withTimeout`)
|
|
39
|
+
* - Per-request and client-level retry (integrates with `retry`)
|
|
40
|
+
* - Request / response / error interceptors
|
|
41
|
+
* - Automatic JSON serialization / deserialization
|
|
42
|
+
* - Query parameter handling
|
|
43
|
+
*
|
|
44
|
+
* @example Basic usage
|
|
45
|
+
* ```ts
|
|
46
|
+
* const http = new HttpClient({ baseUrl: 'https://api.example.com' });
|
|
47
|
+
*
|
|
48
|
+
* const response = await http.get<User>('/users/1');
|
|
49
|
+
* console.log(response.data);
|
|
50
|
+
* ```
|
|
51
|
+
*
|
|
52
|
+
* @example With retry + timeout
|
|
53
|
+
* ```ts
|
|
54
|
+
* const http = new HttpClient({
|
|
55
|
+
* baseUrl: 'https://api.example.com',
|
|
56
|
+
* timeout: 5_000,
|
|
57
|
+
* retry: { retries: 3, backoff: 'exponential', delay: 500 },
|
|
58
|
+
* });
|
|
59
|
+
* ```
|
|
60
|
+
*
|
|
61
|
+
* @example With interceptors
|
|
62
|
+
* ```ts
|
|
63
|
+
* http.interceptors.request.use((config) => {
|
|
64
|
+
* config.headers['Authorization'] = `Bearer ${getToken()}`;
|
|
65
|
+
* return config;
|
|
66
|
+
* });
|
|
67
|
+
*
|
|
68
|
+
* http.interceptors.response.use((res) => {
|
|
69
|
+
* logger.info(`← ${res.status} ${res.raw.url}`);
|
|
70
|
+
* return res;
|
|
71
|
+
* });
|
|
72
|
+
* ```
|
|
73
|
+
*/
|
|
74
|
+
class HttpClient {
|
|
75
|
+
constructor(options = {}) {
|
|
76
|
+
this.interceptors = {
|
|
77
|
+
request: [],
|
|
78
|
+
response: [],
|
|
79
|
+
error: [],
|
|
80
|
+
};
|
|
81
|
+
this.options = {
|
|
82
|
+
baseUrl: options.baseUrl ?? '',
|
|
83
|
+
headers: options.headers ?? {},
|
|
84
|
+
timeout: options.timeout ?? 10000,
|
|
85
|
+
retry: options.retry ?? { retries: 0 },
|
|
86
|
+
};
|
|
87
|
+
}
|
|
88
|
+
// ─── Interceptor registration ─────────────────────────────────────────────
|
|
89
|
+
/** Add a request interceptor. Returns `this` for chaining. */
|
|
90
|
+
useRequestInterceptor(interceptor) {
|
|
91
|
+
this.interceptors.request.push(interceptor);
|
|
92
|
+
return this;
|
|
93
|
+
}
|
|
94
|
+
/** Add a response interceptor. Returns `this` for chaining. */
|
|
95
|
+
useResponseInterceptor(interceptor) {
|
|
96
|
+
this.interceptors.response.push(interceptor);
|
|
97
|
+
return this;
|
|
98
|
+
}
|
|
99
|
+
/** Add an error interceptor. Returns `this` for chaining. */
|
|
100
|
+
useErrorInterceptor(interceptor) {
|
|
101
|
+
this.interceptors.error.push(interceptor);
|
|
102
|
+
return this;
|
|
103
|
+
}
|
|
104
|
+
// ─── HTTP method shortcuts ────────────────────────────────────────────────
|
|
105
|
+
get(url, config) {
|
|
106
|
+
return this.request(url, { ...config, method: 'GET' });
|
|
107
|
+
}
|
|
108
|
+
post(url, body, config) {
|
|
109
|
+
return this.request(url, { ...config, method: 'POST', body });
|
|
110
|
+
}
|
|
111
|
+
put(url, body, config) {
|
|
112
|
+
return this.request(url, { ...config, method: 'PUT', body });
|
|
113
|
+
}
|
|
114
|
+
patch(url, body, config) {
|
|
115
|
+
return this.request(url, { ...config, method: 'PATCH', body });
|
|
116
|
+
}
|
|
117
|
+
delete(url, config) {
|
|
118
|
+
return this.request(url, { ...config, method: 'DELETE' });
|
|
119
|
+
}
|
|
120
|
+
head(url, config) {
|
|
121
|
+
return this.request(url, { ...config, method: 'HEAD' });
|
|
122
|
+
}
|
|
123
|
+
// ─── Core ─────────────────────────────────────────────────────────────────
|
|
124
|
+
async request(path, config = {}) {
|
|
125
|
+
// Resolve config — all fields become required at this point
|
|
126
|
+
let resolvedConfig = {
|
|
127
|
+
url: buildUrl(this.options.baseUrl || undefined, path, config.params),
|
|
128
|
+
method: (config.method ?? 'GET'),
|
|
129
|
+
headers: mergeHeaders(this.options.headers, config.headers),
|
|
130
|
+
body: config.body,
|
|
131
|
+
timeout: config.timeout ?? this.options.timeout,
|
|
132
|
+
retry: config.retry !== undefined ? config.retry : this.options.retry,
|
|
133
|
+
signal: config.signal,
|
|
134
|
+
};
|
|
135
|
+
// Run request interceptors (cast back to ResolvedRequestConfig)
|
|
136
|
+
for (const interceptor of this.interceptors.request) {
|
|
137
|
+
const result = await interceptor(resolvedConfig);
|
|
138
|
+
resolvedConfig = {
|
|
139
|
+
...resolvedConfig,
|
|
140
|
+
...result,
|
|
141
|
+
method: (result.method ?? resolvedConfig.method),
|
|
142
|
+
};
|
|
143
|
+
}
|
|
144
|
+
// Determine effective retry options
|
|
145
|
+
const retryOptions = resolvedConfig.retry ?? false;
|
|
146
|
+
const executeRequest = async () => {
|
|
147
|
+
var _a;
|
|
148
|
+
const controller = resolvedConfig.signal
|
|
149
|
+
? undefined
|
|
150
|
+
: new AbortController();
|
|
151
|
+
const signal = resolvedConfig.signal ?? controller?.signal;
|
|
152
|
+
const fetchOptions = {
|
|
153
|
+
method: resolvedConfig.method,
|
|
154
|
+
headers: resolvedConfig.headers,
|
|
155
|
+
signal,
|
|
156
|
+
};
|
|
157
|
+
if (resolvedConfig.body !== undefined && resolvedConfig.method !== 'GET' && resolvedConfig.method !== 'HEAD') {
|
|
158
|
+
if (typeof resolvedConfig.body === 'object') {
|
|
159
|
+
fetchOptions.body = JSON.stringify(resolvedConfig.body);
|
|
160
|
+
(_a = resolvedConfig.headers)['Content-Type'] ?? (_a['Content-Type'] = 'application/json');
|
|
161
|
+
}
|
|
162
|
+
else {
|
|
163
|
+
fetchOptions.body = resolvedConfig.body;
|
|
164
|
+
}
|
|
165
|
+
}
|
|
166
|
+
let rawResponse;
|
|
167
|
+
try {
|
|
168
|
+
const fetchPromise = fetch(resolvedConfig.url, fetchOptions);
|
|
169
|
+
rawResponse = await (0, timeout_1.withTimeout)(fetchPromise, resolvedConfig.timeout, {
|
|
170
|
+
controller,
|
|
171
|
+
});
|
|
172
|
+
}
|
|
173
|
+
catch (err) {
|
|
174
|
+
if (err instanceof types_1.TimeoutError) {
|
|
175
|
+
throw new types_2.HttpError(err.message, { cause: err });
|
|
176
|
+
}
|
|
177
|
+
throw new types_2.HttpError(err instanceof Error ? err.message : 'Network error', { cause: err });
|
|
178
|
+
}
|
|
179
|
+
if (!rawResponse.ok) {
|
|
180
|
+
const httpError = new types_2.HttpError(`HTTP ${rawResponse.status} ${rawResponse.statusText}`, { status: rawResponse.status, statusText: rawResponse.statusText });
|
|
181
|
+
throw httpError;
|
|
182
|
+
}
|
|
183
|
+
const data = rawResponse.status === 204
|
|
184
|
+
? undefined
|
|
185
|
+
: await parseBody(rawResponse);
|
|
186
|
+
let response = {
|
|
187
|
+
data,
|
|
188
|
+
status: rawResponse.status,
|
|
189
|
+
statusText: rawResponse.statusText,
|
|
190
|
+
headers: rawResponse.headers,
|
|
191
|
+
raw: rawResponse,
|
|
192
|
+
};
|
|
193
|
+
// Run response interceptors
|
|
194
|
+
for (const interceptor of this.interceptors.response) {
|
|
195
|
+
response = (await interceptor(response));
|
|
196
|
+
}
|
|
197
|
+
return response;
|
|
198
|
+
};
|
|
199
|
+
// Wrap in retry if configured
|
|
200
|
+
if (retryOptions !== false && (retryOptions.retries ?? 0) > 0) {
|
|
201
|
+
return (0, retry_1.retry)(executeRequest, retryOptions);
|
|
202
|
+
}
|
|
203
|
+
try {
|
|
204
|
+
return await executeRequest();
|
|
205
|
+
}
|
|
206
|
+
catch (err) {
|
|
207
|
+
if (err instanceof types_2.HttpError) {
|
|
208
|
+
// Run error interceptors
|
|
209
|
+
let current = err;
|
|
210
|
+
for (const interceptor of this.interceptors.error) {
|
|
211
|
+
try {
|
|
212
|
+
return (await interceptor(current));
|
|
213
|
+
}
|
|
214
|
+
catch (next) {
|
|
215
|
+
current = next;
|
|
216
|
+
}
|
|
217
|
+
}
|
|
218
|
+
throw current;
|
|
219
|
+
}
|
|
220
|
+
throw err;
|
|
221
|
+
}
|
|
222
|
+
}
|
|
223
|
+
}
|
|
224
|
+
exports.HttpClient = HttpClient;
|
|
225
|
+
// ─── Convenience factory ──────────────────────────────────────────────────────
|
|
226
|
+
/**
|
|
227
|
+
* Creates a pre-configured {@link HttpClient} instance.
|
|
228
|
+
*
|
|
229
|
+
* @example
|
|
230
|
+
* ```ts
|
|
231
|
+
* const http = createHttpClient({ baseUrl: 'https://api.example.com', timeout: 5_000 });
|
|
232
|
+
* ```
|
|
233
|
+
*/
|
|
234
|
+
function createHttpClient(options) {
|
|
235
|
+
return new HttpClient(options);
|
|
236
|
+
}
|
|
237
|
+
//# sourceMappingURL=HttpClient.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"HttpClient.js","sourceRoot":"","sources":["../../src/http/HttpClient.ts"],"names":[],"mappings":";;;;AAAA,0CAAuC;AACvC,gDAAiD;AACjD,4CAAgD;AAEhD,mCASiB;AAejB,iFAAiF;AAEjF,SAAS,QAAQ,CAAC,IAAwB,EAAE,IAAY,EAAE,MAAoC;IAC1F,MAAM,GAAG,GAAG,IAAI,CAAC,CAAC,CAAC,IAAI,GAAG,CAAC,IAAI,EAAE,IAAI,CAAC,QAAQ,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC,IAAI,CAAC,CAAC,CAAC,IAAI,GAAG,GAAG,CAAC,CAAC,CAAC,CAAC,IAAI,GAAG,CAAC,IAAI,CAAC,CAAC;IAEzF,IAAI,MAAM,EAAE,CAAC;QACT,KAAK,MAAM,CAAC,GAAG,EAAE,KAAK,CAAC,IAAI,MAAM,CAAC,OAAO,CAAC,MAAM,CAAC,EAAE,CAAC;YAChD,IAAI,KAAK,IAAI,IAAI,EAAE,CAAC;gBAChB,GAAG,CAAC,YAAY,CAAC,GAAG,CAAC,GAAG,EAAE,MAAM,CAAC,KAAK,CAAC,CAAC,CAAC;YAC7C,CAAC;QACL,CAAC;IACL,CAAC;IAED,OAAO,GAAG,CAAC,QAAQ,EAAE,CAAC;AAC1B,CAAC;AAED,SAAS,YAAY,CACjB,GAAG,OAAkD;IAErD,OAAO,MAAM,CAAC,MAAM,CAAC,EAAE,EAAE,GAAG,OAAO,CAAC,MAAM,CAAC,OAAO,CAAC,CAAC,CAAC;AACzD,CAAC;AAED,KAAK,UAAU,SAAS,CAAI,QAAkB;IAC1C,MAAM,WAAW,GAAG,QAAQ,CAAC,OAAO,CAAC,GAAG,CAAC,cAAc,CAAC,IAAI,EAAE,CAAC;IAE/D,IAAI,WAAW,CAAC,QAAQ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J;;AAED,iFAAiF;AAEjF;;;;;;;GAOG;AACH,0BAAiC,OAA2B;IACxD,OAAO,IAAI,UAAU,CAAC,OAAO,CAAC,CAAC;AACnC,CAAC"}
|
|
@@ -0,0 +1,4 @@
|
|
|
1
|
+
export { HttpClient, createHttpClient } from './HttpClient';
|
|
2
|
+
export { HttpError } from './types';
|
|
3
|
+
export type { HttpMethod, HttpRequestConfig, HttpResponse, HttpClientOptions, RequestInterceptor, ResponseInterceptor, ErrorInterceptor, } from './types';
|
|
4
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/http/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAE,gBAAgB,EAAE,MAAM,cAAc,CAAC;AAC5D,OAAO,EAAE,SAAS,EAAE,MAAM,SAAS,CAAC;AACpC,YAAY,EACR,UAAU,EACV,iBAAiB,EACjB,YAAY,EACZ,iBAAiB,EACjB,kBAAkB,EAClB,mBAAmB,EACnB,gBAAgB,GACnB,MAAM,SAAS,CAAC"}
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.HttpError = exports.createHttpClient = exports.HttpClient = void 0;
|
|
4
|
+
var HttpClient_1 = require("./HttpClient");
|
|
5
|
+
Object.defineProperty(exports, "HttpClient", { enumerable: true, get: function () { return HttpClient_1.HttpClient; } });
|
|
6
|
+
Object.defineProperty(exports, "createHttpClient", { enumerable: true, get: function () { return HttpClient_1.createHttpClient; } });
|
|
7
|
+
var types_1 = require("./types");
|
|
8
|
+
Object.defineProperty(exports, "HttpError", { enumerable: true, get: function () { return types_1.HttpError; } });
|
|
9
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/http/index.ts"],"names":[],"mappings":";;;AAAA,2CAA4D;AAAnD,wGAAA,UAAU,OAAA;AAAE,8GAAA,gBAAgB,OAAA;AACrC,iCAAoC;AAA3B,kGAAA,SAAS,OAAA"}
|
|
@@ -0,0 +1,78 @@
|
|
|
1
|
+
import type { RetryOptions } from '../retry/types';
|
|
2
|
+
export type HttpMethod = 'GET' | 'POST' | 'PUT' | 'PATCH' | 'DELETE' | 'HEAD' | 'OPTIONS';
|
|
3
|
+
export interface HttpRequestConfig {
|
|
4
|
+
/** HTTP method. @default 'GET' */
|
|
5
|
+
method?: HttpMethod;
|
|
6
|
+
/** Request headers merged with client-level defaults. */
|
|
7
|
+
headers?: Record<string, string>;
|
|
8
|
+
/** Query parameters appended to the URL. */
|
|
9
|
+
params?: Record<string, string | number | boolean | null | undefined>;
|
|
10
|
+
/** Request body. Objects are serialized to JSON automatically. */
|
|
11
|
+
body?: unknown;
|
|
12
|
+
/** Request timeout in ms. Overrides client-level `timeout`. */
|
|
13
|
+
timeout?: number;
|
|
14
|
+
/** Retry policy for this request. Overrides client-level `retry`. */
|
|
15
|
+
retry?: RetryOptions | false;
|
|
16
|
+
/** AbortSignal to cancel the request. */
|
|
17
|
+
signal?: AbortSignal;
|
|
18
|
+
}
|
|
19
|
+
export interface HttpResponse<T = unknown> {
|
|
20
|
+
/** Parsed response body. */
|
|
21
|
+
data: T;
|
|
22
|
+
/** HTTP status code. */
|
|
23
|
+
status: number;
|
|
24
|
+
/** HTTP status text. */
|
|
25
|
+
statusText: string;
|
|
26
|
+
/** Response headers. */
|
|
27
|
+
headers: Headers;
|
|
28
|
+
/** The raw fetch Response object. */
|
|
29
|
+
raw: Response;
|
|
30
|
+
}
|
|
31
|
+
/**
|
|
32
|
+
* Thrown for non-2xx responses and network-level errors.
|
|
33
|
+
*/
|
|
34
|
+
export declare class HttpError extends Error {
|
|
35
|
+
readonly status?: number;
|
|
36
|
+
readonly statusText?: string;
|
|
37
|
+
readonly response?: HttpResponse;
|
|
38
|
+
constructor(message: string, options?: {
|
|
39
|
+
status?: number;
|
|
40
|
+
statusText?: string;
|
|
41
|
+
response?: HttpResponse;
|
|
42
|
+
cause?: unknown;
|
|
43
|
+
});
|
|
44
|
+
}
|
|
45
|
+
/** Receives the outgoing request config and must return (possibly modified) config. */
|
|
46
|
+
export type RequestInterceptor = (config: Readonly<HttpRequestConfig> & {
|
|
47
|
+
url: string;
|
|
48
|
+
}) => (HttpRequestConfig & {
|
|
49
|
+
url: string;
|
|
50
|
+
}) | Promise<HttpRequestConfig & {
|
|
51
|
+
url: string;
|
|
52
|
+
}>;
|
|
53
|
+
/** Receives the parsed response and must return (possibly modified) response. */
|
|
54
|
+
export type ResponseInterceptor<T = unknown> = (response: HttpResponse<T>) => HttpResponse<T> | Promise<HttpResponse<T>>;
|
|
55
|
+
/** Receives an HttpError and can either handle it (returning a response) or re-throw. */
|
|
56
|
+
export type ErrorInterceptor = (error: HttpError) => HttpResponse | Promise<HttpResponse> | never;
|
|
57
|
+
export interface HttpClientOptions {
|
|
58
|
+
/**
|
|
59
|
+
* Base URL prepended to every relative request URL.
|
|
60
|
+
* @example 'https://api.seudominio.com/v1'
|
|
61
|
+
*/
|
|
62
|
+
baseUrl?: string;
|
|
63
|
+
/**
|
|
64
|
+
* Default headers included in every request.
|
|
65
|
+
*/
|
|
66
|
+
headers?: Record<string, string>;
|
|
67
|
+
/**
|
|
68
|
+
* Default timeout in ms for every request.
|
|
69
|
+
* @default 10_000
|
|
70
|
+
*/
|
|
71
|
+
timeout?: number;
|
|
72
|
+
/**
|
|
73
|
+
* Default retry policy. Set `false` to disable retries globally.
|
|
74
|
+
* @default { retries: 0 } (no retries)
|
|
75
|
+
*/
|
|
76
|
+
retry?: RetryOptions | false;
|
|
77
|
+
}
|
|
78
|
+
//# sourceMappingURL=types.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../src/http/types.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,YAA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AAE,MAAM,CAAC;QACpB,QAAQ,CAAC,EAAE,YAAY,CAAC;QACxB,KAAK,CAAC,EAAE,OAAO,CAAC;KACnB,EAYJ;CACJ;AAID,uFAAuF;AACvF,MAAM,MAAM,kBAAkB,GAAG,CAC7B,MAAM,EAAE,QAAQ,CAAC,iBAAiB,CAAC,GAAG;IAAE,GAAG,EAAE,MAAM,CAAA;CAAE,KACpD,CAAA,iBAAiB,GAAG;IAAE,GAAG,EAAE,MAAM,CAAA;CAAE,IAAG,OAAO,CAAC,iBAAiB,GAAG;IAAE,GAAG,EAAE,MAAM,CAAA;CAAE,CAAC,CAAC;AAExF,iFAAiF;AACjF,MAAM,MAAM,mBAAmB,CAAC,CAAC,GAAG,OAAO,IAAI,CAC3C,QAAQ,EAAE,YAAY,CAAC,CAAC,CAAC,KACxB,YAAY,CAAC,CAAC,CAAC,GAAG,OAAO,CAAC,YAAY,CAAC,CAAC,CAAC,CAAC,CAAC;AAEhD,yFAAyF;AACzF,MAAM,MAAM,gBAAgB,GAAG,CAC3B,KAAK,EAAE,SAAS,KACf,YAAY,GAAG,OAAO,CAAC,YAAY,CAAC,GAAG,KAAK,CAAC;AAIlD,MAAM,WAAW,iBAAiB;IAC9B;;;OAGG;IACH,OAAO,CAAC,EAAE,MAAM,CAAC;IAEjB;;OAEG;IACH,OAAO,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;IAEjC;;;OAGG;IACH,OAAO,CAAC,EAAE,MAAM,CAAC;IAEjB;;;OAGG;IACH,KAAK,CAAC,EAAE,YAAY,GAAG,KAAK,CAAC;CAChC"}
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.HttpError = void 0;
|
|
4
|
+
// ─── Error ────────────────────────────────────────────────────────────────────
|
|
5
|
+
/**
|
|
6
|
+
* Thrown for non-2xx responses and network-level errors.
|
|
7
|
+
*/
|
|
8
|
+
class HttpError extends Error {
|
|
9
|
+
constructor(message, options) {
|
|
10
|
+
super(message);
|
|
11
|
+
this.name = 'HttpError';
|
|
12
|
+
this.status = options?.status;
|
|
13
|
+
this.statusText = options?.statusText;
|
|
14
|
+
this.response = options?.response;
|
|
15
|
+
// Attach cause manually for Node 16 / ES2020 compat
|
|
16
|
+
if (options?.cause !== undefined) {
|
|
17
|
+
this['cause'] = options.cause;
|
|
18
|
+
}
|
|
19
|
+
Object.setPrototypeOf(this, new.target.prototype);
|
|
20
|
+
}
|
|
21
|
+
}
|
|
22
|
+
exports.HttpError = HttpError;
|
|
23
|
+
//# sourceMappingURL=types.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"types.js","sourceRoot":"","sources":["../../src/http/types.ts"],"names":[],"mappings":";;;AAwCA,iFAAiF;AAEjF;;GAEG;AACH,eAAuB,SAAQ,KAAK;IAKhC,YACI,OAAe,EACf,OAKC;QAED,KAAK,CAAC,OAAO,CAAC,CAAC;QACf,IAAI,CAAC,IAAI,GAAS,WAAW,CAAC;QAC9B,IAAI,CAAC,MAAM,GAAO,OAAO,EAAE,MAAM,CAAC;QAClC,IAAI,CAAC,UAAU,GAAG,OAAO,EAAE,UAAU,CAAC;QACtC,IAAI,CAAC,QAAQ,GAAK,OAAO,EAAE,QAAQ,CAAC;QACpC,oDAAoD;QACpD,IAAI,OAAO,EAAE,KAAK,KAAK,SAAS,EAAE,CAAC;YAC9B,IAAgC,CAAC,OAAO,CAAC,GAAG,OAAO,CAAC,KAAK,CAAC;QAC/D,CAAC;QACD,MAAM,CAAC,cAAc,CAAC,IAAI,EAAE,IAAI,MAAM,CAAC,SAAS,CAAC,CAAC;IACtD,CAAC;CACJ"}
|
package/dist/index.d.ts
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAGA,cAAc,UAAU,CAAC;AACzB,cAAc,UAAU,CAAC;AACzB,cAAc,SAAS,CAAC;AACxB,cAAc,WAAW,CAAC;AAC1B,cAAc,QAAQ,CAAC"}
|
package/dist/index.js
ADDED
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
// ts-toolkit - Main entry point
|
|
3
|
+
// Re-export all public modules here
|
|
4
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
5
|
+
if (k2 === undefined) k2 = k;
|
|
6
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
7
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
8
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
9
|
+
}
|
|
10
|
+
Object.defineProperty(o, k2, desc);
|
|
11
|
+
}) : (function(o, m, k, k2) {
|
|
12
|
+
if (k2 === undefined) k2 = k;
|
|
13
|
+
o[k2] = m[k];
|
|
14
|
+
}));
|
|
15
|
+
var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
|
16
|
+
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
|
|
17
|
+
};
|
|
18
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
19
|
+
__exportStar(require("./logger"), exports);
|
|
20
|
+
__exportStar(require("./socket"), exports);
|
|
21
|
+
__exportStar(require("./retry"), exports);
|
|
22
|
+
__exportStar(require("./timeout"), exports);
|
|
23
|
+
__exportStar(require("./http"), exports);
|
|
24
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":";AAAA,gCAAgC;AAChC,oCAAoC;;;;;;;;;;;;;;;;AAEpC,2CAAyB;AACzB,2CAAyB;AACzB,0CAAwB;AACxB,4CAA0B;AAC1B,yCAAuB"}
|
|
@@ -0,0 +1,62 @@
|
|
|
1
|
+
import type { LoggerOptions } from './types/LoggerOptions';
|
|
2
|
+
import type { LoggerTransport } from './transports/LoggerTransport';
|
|
3
|
+
/**
|
|
4
|
+
* A transport-based logger with support for:
|
|
5
|
+
* - Multiple stacked transports (Console, HTTP, Discord, File, …)
|
|
6
|
+
* - Per-transport level filtering
|
|
7
|
+
* - Pluggable formatters
|
|
8
|
+
* - Scoped logging
|
|
9
|
+
*
|
|
10
|
+
* @example
|
|
11
|
+
* ```ts
|
|
12
|
+
* const logger = new Logger({ level: LogLevel.DEBUG });
|
|
13
|
+
*
|
|
14
|
+
* logger.use(new ConsoleTransport());
|
|
15
|
+
* logger.use(new HttpTransport({ url: 'https://logs.example.com/api/logs', level: LogLevel.INFO }));
|
|
16
|
+
* logger.use(new DiscordTransport({ webhook: '...', level: LogLevel.ERROR }));
|
|
17
|
+
*
|
|
18
|
+
* logger.info('Server started', { port: 3000 });
|
|
19
|
+
*
|
|
20
|
+
* const dbLogger = logger.scope('Database');
|
|
21
|
+
* dbLogger.error('Connection failed', { retry: 3 });
|
|
22
|
+
* ```
|
|
23
|
+
*/
|
|
24
|
+
export declare class Logger {
|
|
25
|
+
private readonly transports;
|
|
26
|
+
private readonly minimumLevel;
|
|
27
|
+
private readonly currentScope?;
|
|
28
|
+
constructor(options?: LoggerOptions);
|
|
29
|
+
/**
|
|
30
|
+
* Register a transport. Transports are called in registration order.
|
|
31
|
+
* Returns `this` so calls can be chained.
|
|
32
|
+
*
|
|
33
|
+
* @example
|
|
34
|
+
* ```ts
|
|
35
|
+
* logger
|
|
36
|
+
* .use(new ConsoleTransport())
|
|
37
|
+
* .use(new FileTransport({ filePath: './app.log' }));
|
|
38
|
+
* ```
|
|
39
|
+
*/
|
|
40
|
+
use(transport: LoggerTransport): this;
|
|
41
|
+
/**
|
|
42
|
+
* Returns a new Logger instance with the given scope attached to every entry.
|
|
43
|
+
* The parent logger's transports are shared (not copied).
|
|
44
|
+
*
|
|
45
|
+
* @example
|
|
46
|
+
* ```ts
|
|
47
|
+
* const dbLogger = logger.scope('Database');
|
|
48
|
+
* dbLogger.info('Connected'); // → [Database] Connected
|
|
49
|
+
* dbLogger.error('Query failed'); // → [Database] Query failed
|
|
50
|
+
* ```
|
|
51
|
+
*/
|
|
52
|
+
scope(name: string): Logger;
|
|
53
|
+
trace(message: string, context?: Record<string, unknown>): void;
|
|
54
|
+
debug(message: string, context?: Record<string, unknown>): void;
|
|
55
|
+
info(message: string, context?: Record<string, unknown>): void;
|
|
56
|
+
success(message: string, context?: Record<string, unknown>): void;
|
|
57
|
+
warn(message: string, context?: Record<string, unknown>): void;
|
|
58
|
+
error(message: string, context?: Record<string, unknown>): void;
|
|
59
|
+
fatal(message: string, context?: Record<string, unknown>): void;
|
|
60
|
+
private _dispatch;
|
|
61
|
+
}
|
|
62
|
+
//# sourceMappingURL=Logger.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"Logger.d.ts","sourceRoot":"","sources":["../../src/logger/Logger.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,uBAAuB,CAAC;AAC3D,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,8BAA8B,CAAC;AAEpE;;;;;;;;;;;;;;;;;;;;GAoBG;AACH,qBAAa,MAAM;IACf,OAAO,CAAC,QAAQ,CAAC,UAAU,CAAyB;IACpD,OAAO,CAAC,QAAQ,CAAC,YAAY,CAAW;IACxC,OAAO,CAAC,QAAQ,CAAC,YAAY,CAAC,CAAS;IAEvC,YAAY,OAAO,GAAE,aAAkB,EAGtC;IAID;;;;;;;;;;OAUG;IACH,GAAG,CAAC,SAAS,EAAE,eAAe,GAAG,IAAI,CAGpC;IAID;;;;;;;;;;OAUG;IACH,KAAK,CAAC,IAAI,EAAE,MAAM,GAAG,MAAM,CAY1B;IAID,KAAK,CAAC,OAAO,EAAE,MAAM,EAAE,OAAO,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,GAAG,IAAI,CAE9D;IAED,KAA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