bytekit 2.2.3 → 2.4.3

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 (70) hide show
  1. package/dist/cli/index.js +7 -4
  2. package/dist/cli/index.js.map +1 -1
  3. package/dist/cli/swagger-generator.d.ts.map +1 -1
  4. package/dist/cli/swagger-generator.js +9 -0
  5. package/dist/cli/swagger-generator.js.map +1 -1
  6. package/dist/cli/type-generator.d.ts.map +1 -1
  7. package/dist/cli/type-generator.js +5 -0
  8. package/dist/cli/type-generator.js.map +1 -1
  9. package/dist/utils/async/request-batcher.d.ts.map +1 -1
  10. package/dist/utils/async/request-batcher.js +1 -0
  11. package/dist/utils/async/request-batcher.js.map +1 -1
  12. package/dist/utils/async/throttle.d.ts.map +1 -1
  13. package/dist/utils/async/throttle.js +1 -0
  14. package/dist/utils/async/throttle.js.map +1 -1
  15. package/dist/utils/core/ApiClient.d.ts.map +1 -1
  16. package/dist/utils/core/ApiClient.js +12 -1
  17. package/dist/utils/core/ApiClient.js.map +1 -1
  18. package/dist/utils/core/ErrorBoundary.d.ts.map +1 -1
  19. package/dist/utils/core/ErrorBoundary.js +18 -5
  20. package/dist/utils/core/ErrorBoundary.js.map +1 -1
  21. package/dist/utils/core/Logger.d.ts +191 -0
  22. package/dist/utils/core/Logger.d.ts.map +1 -1
  23. package/dist/utils/core/Logger.js +155 -0
  24. package/dist/utils/core/Logger.js.map +1 -1
  25. package/dist/utils/core/Profiler.d.ts +41 -0
  26. package/dist/utils/core/Profiler.d.ts.map +1 -1
  27. package/dist/utils/core/Profiler.js +59 -0
  28. package/dist/utils/core/Profiler.js.map +1 -1
  29. package/dist/utils/core/RateLimiter.d.ts.map +1 -1
  30. package/dist/utils/core/RateLimiter.js +2 -0
  31. package/dist/utils/core/RateLimiter.js.map +1 -1
  32. package/dist/utils/core/ResponseValidator.d.ts +56 -0
  33. package/dist/utils/core/ResponseValidator.d.ts.map +1 -1
  34. package/dist/utils/core/ResponseValidator.js +28 -0
  35. package/dist/utils/core/ResponseValidator.js.map +1 -1
  36. package/dist/utils/core/RetryPolicy.d.ts +144 -0
  37. package/dist/utils/core/RetryPolicy.d.ts.map +1 -1
  38. package/dist/utils/core/RetryPolicy.js +108 -0
  39. package/dist/utils/core/RetryPolicy.js.map +1 -1
  40. package/dist/utils/helpers/CacheManager.d.ts.map +1 -1
  41. package/dist/utils/helpers/CacheManager.js +5 -0
  42. package/dist/utils/helpers/CacheManager.js.map +1 -1
  43. package/dist/utils/helpers/CompressionUtils.d.ts.map +1 -1
  44. package/dist/utils/helpers/CompressionUtils.js +21 -4
  45. package/dist/utils/helpers/CompressionUtils.js.map +1 -1
  46. package/dist/utils/helpers/CryptoUtils.d.ts.map +1 -1
  47. package/dist/utils/helpers/CryptoUtils.js +15 -3
  48. package/dist/utils/helpers/CryptoUtils.js.map +1 -1
  49. package/dist/utils/helpers/EnvManager.d.ts +46 -0
  50. package/dist/utils/helpers/EnvManager.d.ts.map +1 -1
  51. package/dist/utils/helpers/EnvManager.js +46 -0
  52. package/dist/utils/helpers/EnvManager.js.map +1 -1
  53. package/dist/utils/helpers/EventEmitter.d.ts.map +1 -1
  54. package/dist/utils/helpers/EventEmitter.js +0 -3
  55. package/dist/utils/helpers/EventEmitter.js.map +1 -1
  56. package/dist/utils/helpers/StorageUtils.d.ts +62 -0
  57. package/dist/utils/helpers/StorageUtils.d.ts.map +1 -1
  58. package/dist/utils/helpers/StorageUtils.js +62 -0
  59. package/dist/utils/helpers/StorageUtils.js.map +1 -1
  60. package/dist/utils/helpers/StreamingHelper.d.ts.map +1 -1
  61. package/dist/utils/helpers/StreamingHelper.js +7 -1
  62. package/dist/utils/helpers/StreamingHelper.js.map +1 -1
  63. package/dist/utils/helpers/UrlHelper.d.ts +30 -0
  64. package/dist/utils/helpers/UrlHelper.d.ts.map +1 -1
  65. package/dist/utils/helpers/UrlHelper.js +23 -1
  66. package/dist/utils/helpers/UrlHelper.js.map +1 -1
  67. package/dist/utils/helpers/WebSocketHelper.d.ts.map +1 -1
  68. package/dist/utils/helpers/WebSocketHelper.js +6 -2
  69. package/dist/utils/helpers/WebSocketHelper.js.map +1 -1
  70. package/package.json +1 -1
@@ -1,39 +1,230 @@
1
+ /**
2
+ * Ordered severity levels for the logger.
3
+ *
4
+ * Levels from lowest to highest priority: `debug` < `info` < `warn` < `error`.
5
+ * Setting the level to `"silent"` suppresses all output.
6
+ */
1
7
  export type LogLevel = "silent" | "error" | "warn" | "info" | "debug";
8
+ /**
9
+ * A single structured log entry passed to every {@link LogTransport}.
10
+ *
11
+ * @template TContext - Shape of the optional context object attached to the entry.
12
+ */
2
13
  export interface LogEntry<TContext extends Record<string, unknown> = Record<string, unknown>> {
14
+ /** Severity level of the log entry. */
3
15
  level: LogLevel;
16
+ /** Human-readable log message. */
4
17
  message: string;
18
+ /** Optional dot-separated namespace of the logger that emitted the entry. */
5
19
  namespace?: string;
20
+ /** Exact time the entry was created. */
6
21
  timestamp: Date;
22
+ /** Optional structured context payload for machine-readable metadata. */
7
23
  context?: TContext;
24
+ /** Optional `Error` object associated with the log entry. */
8
25
  error?: Error;
9
26
  }
27
+ /**
28
+ * A function that receives a {@link LogEntry} and writes it to an output
29
+ * destination. Transports may be synchronous or asynchronous.
30
+ *
31
+ * Uncaught rejections from async transports are caught by the {@link Logger}
32
+ * and reported to `console.error`.
33
+ */
10
34
  export type LogTransport = (entry: LogEntry) => void | Promise<void>;
35
+ /** Configuration options for the {@link Logger} constructor. */
11
36
  export interface LoggerOptions {
37
+ /** Dot-separated namespace prepended to every log message (e.g., `"app:db"`). */
12
38
  namespace?: string;
39
+ /**
40
+ * Minimum severity level to emit.
41
+ * Defaults to `"debug"` in development and `"info"` in production.
42
+ */
13
43
  level?: LogLevel;
44
+ /**
45
+ * Custom transport functions to use instead of the default console transport.
46
+ * When omitted, a console transport is selected automatically based on runtime.
47
+ */
14
48
  transports?: LogTransport[];
49
+ /**
50
+ * Whether to prefix log entries with an ISO 8601 timestamp in the default
51
+ * console transport. Defaults to `true`.
52
+ */
15
53
  includeTimestamp?: boolean;
16
54
  }
55
+ /**
56
+ * Creates a transport that writes coloured log entries to the Node.js console
57
+ * using ANSI escape codes.
58
+ *
59
+ * Each severity level is rendered in a distinct colour: red (error),
60
+ * yellow (warn), green (info), and grey (debug).
61
+ *
62
+ * @param options - Transport configuration.
63
+ * @param options.includeTimestamp - Prefix each entry with an ISO 8601
64
+ * timestamp. Defaults to `true`.
65
+ * @returns A {@link LogTransport} for use in Node.js environments.
66
+ *
67
+ * @example
68
+ * ```typescript
69
+ * const logger = new Logger({
70
+ * transports: [consoleTransportNode({ includeTimestamp: false })],
71
+ * });
72
+ * logger.info('Server started');
73
+ * ```
74
+ */
17
75
  export declare const consoleTransportNode: ({ includeTimestamp, }?: {
18
76
  includeTimestamp?: boolean;
19
77
  }) => LogTransport;
78
+ /**
79
+ * Creates a transport that writes styled log entries to the browser console
80
+ * using `%c` CSS colour formatting.
81
+ *
82
+ * Each severity level is rendered in a distinct colour: red (error),
83
+ * orange (warn), green (info), and grey (debug).
84
+ *
85
+ * @param options - Transport configuration.
86
+ * @param options.includeTimestamp - Prefix each entry with an ISO 8601
87
+ * timestamp. Defaults to `true`.
88
+ * @returns A {@link LogTransport} for use in browser environments.
89
+ *
90
+ * @example
91
+ * ```typescript
92
+ * const logger = new Logger({
93
+ * transports: [consoleTransportBrowser()],
94
+ * });
95
+ * logger.warn('Low memory');
96
+ * ```
97
+ */
20
98
  export declare const consoleTransportBrowser: ({ includeTimestamp, }?: {
21
99
  includeTimestamp?: boolean;
22
100
  }) => LogTransport;
101
+ /**
102
+ * Structured, transport-based logger with namespace and level filtering.
103
+ *
104
+ * Automatically selects a console transport based on the runtime environment
105
+ * (Node.js or browser) when no custom transports are provided. Supports
106
+ * child loggers for hierarchical namespacing.
107
+ *
108
+ * @template TContext - Shape of the structured context object attached to
109
+ * log entries.
110
+ *
111
+ * @example
112
+ * ```typescript
113
+ * const logger = new Logger({ namespace: 'app', level: 'info' });
114
+ * logger.info('Server started', { port: 3000 });
115
+ *
116
+ * const dbLogger = logger.child('db');
117
+ * dbLogger.debug('Query executed', { sql: 'SELECT 1' });
118
+ * ```
119
+ */
23
120
  export declare class Logger<TContext extends Record<string, unknown> = Record<string, unknown>> {
24
121
  private readonly namespace?;
25
122
  private readonly transports;
26
123
  private level;
124
+ /**
125
+ * Creates a new `Logger` instance.
126
+ *
127
+ * @param options - Logger configuration. All fields are optional.
128
+ */
27
129
  constructor({ namespace, level, transports, includeTimestamp, }?: LoggerOptions);
130
+ /**
131
+ * Updates the minimum log level at runtime.
132
+ *
133
+ * @param level - The new minimum severity level to emit.
134
+ */
28
135
  setLevel(level: LogLevel): void;
136
+ /**
137
+ * Creates a child logger that inherits this logger's level and transports.
138
+ *
139
+ * The child's namespace is formed by appending `namespace` to the parent's
140
+ * namespace with a colon separator (e.g., `"app"` → `"app:db"`).
141
+ *
142
+ * @param namespace - Namespace segment to append.
143
+ * @returns A new `Logger` instance scoped to the child namespace.
144
+ *
145
+ * @example
146
+ * ```typescript
147
+ * const child = logger.child('db');
148
+ * child.debug('Connected'); // emits "[app:db] Connected"
149
+ * ```
150
+ */
29
151
  child(namespace: string): Logger<TContext>;
152
+ /**
153
+ * Emits a `debug`-level log entry.
154
+ *
155
+ * @param message - Human-readable description of the event.
156
+ * @param context - Optional structured metadata to attach.
157
+ */
30
158
  debug(message: string, context?: TContext): void;
159
+ /**
160
+ * Emits an `info`-level log entry.
161
+ *
162
+ * @param message - Human-readable description of the event.
163
+ * @param context - Optional structured metadata to attach.
164
+ */
31
165
  info(message: string, context?: TContext): void;
166
+ /**
167
+ * Emits a `warn`-level log entry.
168
+ *
169
+ * @param message - Human-readable description of the event.
170
+ * @param context - Optional structured metadata to attach.
171
+ */
32
172
  warn(message: string, context?: TContext): void;
173
+ /**
174
+ * Emits an `error`-level log entry.
175
+ *
176
+ * @param message - Human-readable description of the event.
177
+ * @param context - Optional structured metadata to attach.
178
+ * @param error - Optional `Error` object to include in the entry.
179
+ */
33
180
  error(message: string, context?: TContext, error?: Error): void;
181
+ /**
182
+ * Low-level method to emit a log entry at any level.
183
+ *
184
+ * Skips emission when `level` is below the configured minimum.
185
+ * Transport failures are caught and reported to `console.error`.
186
+ *
187
+ * @param level - Severity level for the entry.
188
+ * @param message - Human-readable description of the event.
189
+ * @param context - Optional structured metadata to attach.
190
+ * @param error - Optional `Error` object to include in the entry.
191
+ *
192
+ * @example
193
+ * ```typescript
194
+ * logger.log('info', 'Custom event', { traceId: 'abc' });
195
+ * ```
196
+ */
34
197
  log(level: LogLevel, message: string, context?: TContext, error?: Error): void;
198
+ /** @internal */
35
199
  private shouldLog;
200
+ /**
201
+ * Creates a `Logger` that suppresses all output.
202
+ *
203
+ * Useful for disabling logging in test environments.
204
+ *
205
+ * @returns A new `Logger` configured with level `"silent"`.
206
+ *
207
+ * @example
208
+ * ```typescript
209
+ * const logger = Logger.silent();
210
+ * logger.debug('This is never printed');
211
+ * ```
212
+ */
36
213
  static silent(): Logger<Record<string, unknown>>;
37
214
  }
215
+ /**
216
+ * Factory function that creates a new {@link Logger} instance.
217
+ *
218
+ * A convenience wrapper around `new Logger(options)`.
219
+ *
220
+ * @param options - Logger configuration. All fields are optional.
221
+ * @returns A configured `Logger` instance.
222
+ *
223
+ * @example
224
+ * ```typescript
225
+ * const logger = createLogger({ namespace: 'api', level: 'warn' });
226
+ * logger.warn('Rate limit approaching');
227
+ * ```
228
+ */
38
229
  export declare const createLogger: (options?: LoggerOptions) => Logger<Record<string, unknown>>;
39
230
  //# sourceMappingURL=Logger.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"Logger.d.ts","sourceRoot":"","sources":["../../../src/utils/core/Logger.ts"],"names":[],"mappings":"AACA,MAAM,MAAM,QAAQ,GAAG,QAAQ,GAAG,OAAO,GAAG,MAAM,GAAG,MAAM,GAAG,OAAO,CAAC;AAEtE,MAAM,WAAW,QAAQ,CACrB,QAAQ,SAAS,MAAM,CAAC,MAAM,EA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EAAE,QAAQ;IAIxC;;;;;;OAMG;IACH,KAAK,CAAC,OAAO,EAAE,MAAM,EAAE,OAAO,CAAC,EAAE,QAAQ,EAAE,KAAK,CAAC,EAAE,KAAK;IAIxD;;;;;;;;;;;;;;;OAeG;IACH,GAAG,CAAC,KAAK,EAAE,QAAQ,EAAE,OAAO,EAAE,MAAM,EAAE,OAAO,CAAC,EAAE,QAAQ,EAAE,KAAK,CAAC,EAAE,KAAK;IAmBvE,gBAAgB;IAChB,OAAO,CAAC,SAAS;IAKjB;;;;;;;;;;;;OAYG;IACH,MAAM,CAAC,MAAM;CAGhB;AAMD;;;;;;;;;;;;;GAaG;AACH,eAAO,MAAM,YAAY,GAAI,UAAU,aAAa,oCAAwB,CAAC"}
@@ -1,3 +1,4 @@
1
+ /* eslint-disable no-console */
1
2
  // ------------------------------------
2
3
  // Config & Constants
3
4
  // ------------------------------------
@@ -15,6 +16,26 @@ const isBrowser = typeof window !== "undefined" && typeof document !== "undefine
15
16
  // ------------------------------------
16
17
  // Transports
17
18
  // ------------------------------------
19
+ /**
20
+ * Creates a transport that writes coloured log entries to the Node.js console
21
+ * using ANSI escape codes.
22
+ *
23
+ * Each severity level is rendered in a distinct colour: red (error),
24
+ * yellow (warn), green (info), and grey (debug).
25
+ *
26
+ * @param options - Transport configuration.
27
+ * @param options.includeTimestamp - Prefix each entry with an ISO 8601
28
+ * timestamp. Defaults to `true`.
29
+ * @returns A {@link LogTransport} for use in Node.js environments.
30
+ *
31
+ * @example
32
+ * ```typescript
33
+ * const logger = new Logger({
34
+ * transports: [consoleTransportNode({ includeTimestamp: false })],
35
+ * });
36
+ * logger.info('Server started');
37
+ * ```
38
+ */
18
39
  export const consoleTransportNode = ({ includeTimestamp = true, } = {}) => {
19
40
  const COLORS = {
20
41
  error: "\x1b[31m", // rojo
@@ -47,6 +68,26 @@ export const consoleTransportNode = ({ includeTimestamp = true, } = {}) => {
47
68
  method(...payload);
48
69
  };
49
70
  };
71
+ /**
72
+ * Creates a transport that writes styled log entries to the browser console
73
+ * using `%c` CSS colour formatting.
74
+ *
75
+ * Each severity level is rendered in a distinct colour: red (error),
76
+ * orange (warn), green (info), and grey (debug).
77
+ *
78
+ * @param options - Transport configuration.
79
+ * @param options.includeTimestamp - Prefix each entry with an ISO 8601
80
+ * timestamp. Defaults to `true`.
81
+ * @returns A {@link LogTransport} for use in browser environments.
82
+ *
83
+ * @example
84
+ * ```typescript
85
+ * const logger = new Logger({
86
+ * transports: [consoleTransportBrowser()],
87
+ * });
88
+ * logger.warn('Low memory');
89
+ * ```
90
+ */
50
91
  export const consoleTransportBrowser = ({ includeTimestamp = true, } = {}) => {
51
92
  const COLORS = {
52
93
  error: "color: red",
@@ -57,6 +98,7 @@ export const consoleTransportBrowser = ({ includeTimestamp = true, } = {}) => {
57
98
  };
58
99
  return (entry) => {
59
100
  const { level, message, namespace, timestamp, context, error } = entry;
101
+ /* v8 ignore next */
60
102
  const color = COLORS[level] ?? "";
61
103
  const prefixParts = [];
62
104
  if (includeTimestamp)
@@ -81,7 +123,31 @@ export const consoleTransportBrowser = ({ includeTimestamp = true, } = {}) => {
81
123
  // ------------------------------------
82
124
  // Logger Class
83
125
  // ------------------------------------
126
+ /**
127
+ * Structured, transport-based logger with namespace and level filtering.
128
+ *
129
+ * Automatically selects a console transport based on the runtime environment
130
+ * (Node.js or browser) when no custom transports are provided. Supports
131
+ * child loggers for hierarchical namespacing.
132
+ *
133
+ * @template TContext - Shape of the structured context object attached to
134
+ * log entries.
135
+ *
136
+ * @example
137
+ * ```typescript
138
+ * const logger = new Logger({ namespace: 'app', level: 'info' });
139
+ * logger.info('Server started', { port: 3000 });
140
+ *
141
+ * const dbLogger = logger.child('db');
142
+ * dbLogger.debug('Query executed', { sql: 'SELECT 1' });
143
+ * ```
144
+ */
84
145
  export class Logger {
146
+ /**
147
+ * Creates a new `Logger` instance.
148
+ *
149
+ * @param options - Logger configuration. All fields are optional.
150
+ */
85
151
  constructor({ namespace, level = DEFAULT_LEVEL, transports, includeTimestamp, } = {}) {
86
152
  Object.defineProperty(this, "namespace", {
87
153
  enumerable: true,
@@ -113,9 +179,29 @@ export class Logger {
113
179
  : consoleTransportNode({ includeTimestamp }),
114
180
  ];
115
181
  }
182
+ /**
183
+ * Updates the minimum log level at runtime.
184
+ *
185
+ * @param level - The new minimum severity level to emit.
186
+ */
116
187
  setLevel(level) {
117
188
  this.level = level;
118
189
  }
190
+ /**
191
+ * Creates a child logger that inherits this logger's level and transports.
192
+ *
193
+ * The child's namespace is formed by appending `namespace` to the parent's
194
+ * namespace with a colon separator (e.g., `"app"` → `"app:db"`).
195
+ *
196
+ * @param namespace - Namespace segment to append.
197
+ * @returns A new `Logger` instance scoped to the child namespace.
198
+ *
199
+ * @example
200
+ * ```typescript
201
+ * const child = logger.child('db');
202
+ * child.debug('Connected'); // emits "[app:db] Connected"
203
+ * ```
204
+ */
119
205
  child(namespace) {
120
206
  const childNamespace = this.namespace
121
207
  ? `${this.namespace}:${namespace}`
@@ -126,18 +212,59 @@ export class Logger {
126
212
  transports: this.transports,
127
213
  });
128
214
  }
215
+ /**
216
+ * Emits a `debug`-level log entry.
217
+ *
218
+ * @param message - Human-readable description of the event.
219
+ * @param context - Optional structured metadata to attach.
220
+ */
129
221
  debug(message, context) {
130
222
  this.log("debug", message, context);
131
223
  }
224
+ /**
225
+ * Emits an `info`-level log entry.
226
+ *
227
+ * @param message - Human-readable description of the event.
228
+ * @param context - Optional structured metadata to attach.
229
+ */
132
230
  info(message, context) {
133
231
  this.log("info", message, context);
134
232
  }
233
+ /**
234
+ * Emits a `warn`-level log entry.
235
+ *
236
+ * @param message - Human-readable description of the event.
237
+ * @param context - Optional structured metadata to attach.
238
+ */
135
239
  warn(message, context) {
136
240
  this.log("warn", message, context);
137
241
  }
242
+ /**
243
+ * Emits an `error`-level log entry.
244
+ *
245
+ * @param message - Human-readable description of the event.
246
+ * @param context - Optional structured metadata to attach.
247
+ * @param error - Optional `Error` object to include in the entry.
248
+ */
138
249
  error(message, context, error) {
139
250
  this.log("error", message, context, error);
140
251
  }
252
+ /**
253
+ * Low-level method to emit a log entry at any level.
254
+ *
255
+ * Skips emission when `level` is below the configured minimum.
256
+ * Transport failures are caught and reported to `console.error`.
257
+ *
258
+ * @param level - Severity level for the entry.
259
+ * @param message - Human-readable description of the event.
260
+ * @param context - Optional structured metadata to attach.
261
+ * @param error - Optional `Error` object to include in the entry.
262
+ *
263
+ * @example
264
+ * ```typescript
265
+ * logger.log('info', 'Custom event', { traceId: 'abc' });
266
+ * ```
267
+ */
141
268
  log(level, message, context, error) {
142
269
  if (!this.shouldLog(level))
143
270
  return;
@@ -153,11 +280,25 @@ export class Logger {
153
280
  Promise.resolve(transport(entry)).catch((err) => console.error("[Logger] Transport failure", err));
154
281
  }
155
282
  }
283
+ /** @internal */
156
284
  shouldLog(level) {
157
285
  if (this.level === "silent")
158
286
  return false;
159
287
  return LEVEL_PRIORITY[level] <= LEVEL_PRIORITY[this.level];
160
288
  }
289
+ /**
290
+ * Creates a `Logger` that suppresses all output.
291
+ *
292
+ * Useful for disabling logging in test environments.
293
+ *
294
+ * @returns A new `Logger` configured with level `"silent"`.
295
+ *
296
+ * @example
297
+ * ```typescript
298
+ * const logger = Logger.silent();
299
+ * logger.debug('This is never printed');
300
+ * ```
301
+ */
161
302
  static silent() {
162
303
  return new Logger({ level: "silent" });
163
304
  }
@@ -165,5 +306,19 @@ export class Logger {
165
306
  // ------------------------------------
166
307
  // Factory
167
308
  // ------------------------------------
309
+ /**
310
+ * Factory function that creates a new {@link Logger} instance.
311
+ *
312
+ * A convenience wrapper around `new Logger(options)`.
313
+ *
314
+ * @param options - Logger configuration. All fields are optional.
315
+ * @returns A configured `Logger` instance.
316
+ *
317
+ * @example
318
+ * ```typescript
319
+ * const logger = createLogger({ namespace: 'api', level: 'warn' });
320
+ * logger.warn('Rate limit approaching');
321
+ * ```
322
+ */
168
323
  export const createLogger = (options) => new Logger(options);
169
324
  //# sourceMappingURL=Logger.js.map
@@ -1 +1 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AAC,IAAI,CAAC,SAAS,CAAC,KAAK,CAAC;YAAE,OAAO;QAEnC,MAAM,KAAK,GAAuB;YAC9B,KAAK;YACL,OAAO;YACP,SAAS,EAAE,IAAI,CAAC,SAAS;YACzB,SAAS,EAAE,IAAI,IAAI,EAAE;YACrB,OAAO;YACP,KAAK;SACR,CAAC;QAEF,KAAK,MAAM,SAAS,IAAI,IAAI,CAAC,UAAU,EAAE,CAAC;YACtC,OAAO,CAAC,OAAO,CAAC,SAAS,CAAC,KAAK,CAAC,CAAC,CAAC,KAAK,CAAC,CAAC,GAAG,EAAE,EAAE,CAC5C,OAAO,CAAC,KAAK,CAAC,4BAA4B,EAAE,GAAG,CAAC,CACnD,CAAC;QACN,CAAC;IACL,CAAC;IAED,gBAAgB;IACR,SAAS,CAAC,KAAe;QAC7B,IAAI,IAAI,CAAC,KAAK,KAAK,QAAQ;YAAE,OAAO,KAAK,CAAC;QAC1C,OAAO,cAAc,CAAC,KAAK,CAAC,IAAI,cAAc,CAAC,IAAI,CAAC,KAAK,CAAC,CAAC;IAC/D,CAAC;IAED;;;;;;;;;;;;OAYG;IACH,MAAM,CAAC,MAAM;QACT,OAAO,IAAI,MAAM,CAAC,EAAE,KAAK,EAAE,QAAQ,EAAE,CAAC,CAAC;IAC3C,CAAC;CACJ;AAED,uCAAuC;AACvC,UAAU;AACV,uCAAuC;AAEvC;;;;;;;;;;;;;GAaG;AACH,MAAM,CAAC,MAAM,YAAY,GAAG,CAAC,OAAuB,EAAE,EAAE,CAAC,IAAI,MAAM,CAAC,OAAO,CAAC,CAAC"}
@@ -1,9 +1,50 @@
1
+ /**
2
+ * Lightweight performance profiler for measuring execution durations.
3
+ *
4
+ * Supports optional namespacing so that results from multiple profiler
5
+ * instances can be distinguished in a shared metrics report.
6
+ *
7
+ * @example
8
+ * ```typescript
9
+ * const profiler = new Profiler('db');
10
+ * profiler.start('query');
11
+ * await runQuery();
12
+ * profiler.end('query');
13
+ * console.log(profiler.summary()); // { db: { query: 12.34 } }
14
+ * ```
15
+ */
1
16
  export declare class Profiler {
2
17
  private stack;
3
18
  private results;
4
19
  private namespace?;
20
+ /**
21
+ * Creates a new `Profiler` instance.
22
+ *
23
+ * @param namespace - Optional label used to group results in the
24
+ * {@link Profiler.summary} output. When omitted, results are flat.
25
+ */
5
26
  constructor(namespace?: string);
27
+ /**
28
+ * Records the start time for a named measurement.
29
+ *
30
+ * @param label - Unique name for the measurement being started.
31
+ */
6
32
  start(label: string): void;
33
+ /**
34
+ * Records the end time for a named measurement and stores the duration.
35
+ *
36
+ * Uses `performance.now()` for high-resolution timing. Silently ignored
37
+ * when no matching {@link Profiler.start} call exists for `label`.
38
+ *
39
+ * @param label - Name of the measurement to complete.
40
+ *
41
+ * @example
42
+ * ```typescript
43
+ * profiler.start('render');
44
+ * render();
45
+ * profiler.end('render');
46
+ * ```
47
+ */
7
48
  end(label: string): void;
8
49
  summary(): Record<string, number> | Record<string, Record<string, number>>;
9
50
  }
@@ -1 +1 @@
1
- {"version":3,"file":"Profiler.d.ts","sourceRoot":"","sources":["../../../src/utils/core/Profiler.ts"],"names":[],"mappings":"AAAA,qBAAa,QAAQ;IACjB,OAAO,CAAC,KAAK,CAA0C;IACvD,OAAO,CAAC,OAAO,CAA8C;IAC7D,OAAO,CAAC,SAAS,CAAC,CAAS;gBAEf,SAAS,CAAC,EAAE,MAAM;IAI9B,KAAK,CAAC,KAAK,EAAE,MAAM;IAInB,GAAG,CAAC,KAAK,EAAE,MAAM;IAejB,OAAO;CAOV"}
1
+ {"version":3,"file":"Profiler.d.ts","sourceRoot":"","sources":["../../../src/utils/core/Profiler.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;GAcG;AACH,qBAAa,QAAQ;IACjB,OAAO,CAAC,KAAK,CAA0C;IACvD,OAAO,CAAC,OAAO,CAA8C;IAC7D,OAAO,CAAC,SAAS,CAAC,CAAS;IAE3B;;;;;OAKG;gBACS,SAAS,CAAC,EAAE,MAAM;IAsB9B;;;;OAIG;IACH,KAAK,CAAC,KAAK,EAAE,MAAM;IAInB;;;;;;;;;;;;;;OAcG;IACH,GAAG,CAAC,KAAK,EAAE,MAAM;IAejB,OAAO;CAOV"}
@@ -1,4 +1,25 @@
1
+ /**
2
+ * Lightweight performance profiler for measuring execution durations.
3
+ *
4
+ * Supports optional namespacing so that results from multiple profiler
5
+ * instances can be distinguished in a shared metrics report.
6
+ *
7
+ * @example
8
+ * ```typescript
9
+ * const profiler = new Profiler('db');
10
+ * profiler.start('query');
11
+ * await runQuery();
12
+ * profiler.end('query');
13
+ * console.log(profiler.summary()); // { db: { query: 12.34 } }
14
+ * ```
15
+ */
1
16
  export class Profiler {
17
+ /**
18
+ * Creates a new `Profiler` instance.
19
+ *
20
+ * @param namespace - Optional label used to group results in the
21
+ * {@link Profiler.summary} output. When omitted, results are flat.
22
+ */
2
23
  constructor(namespace) {
3
24
  Object.defineProperty(this, "stack", {
4
25
  enumerable: true,
@@ -19,10 +40,48 @@ export class Profiler {
19
40
  value: void 0
20
41
  });
21
42
  this.namespace = namespace;
43
+ /**
44
+ * Returns all recorded durations.
45
+ *
46
+ * When a namespace was provided to the constructor, results are grouped
47
+ * under that key. Without a namespace, a flat `Record<string, number>`
48
+ * is returned for backwards compatibility.
49
+ *
50
+ * @returns A map of label → duration (ms), optionally nested by namespace.
51
+ *
52
+ * @example
53
+ * ```typescript
54
+ * // Without namespace:
55
+ * profiler.summary(); // { query: 12.34, render: 5.67 }
56
+ *
57
+ * // With namespace 'db':
58
+ * profiler.summary(); // { db: { query: 12.34 } }
59
+ * ```
60
+ */
22
61
  }
62
+ /**
63
+ * Records the start time for a named measurement.
64
+ *
65
+ * @param label - Unique name for the measurement being started.
66
+ */
23
67
  start(label) {
24
68
  this.stack.push({ label, start: performance.now() });
25
69
  }
70
+ /**
71
+ * Records the end time for a named measurement and stores the duration.
72
+ *
73
+ * Uses `performance.now()` for high-resolution timing. Silently ignored
74
+ * when no matching {@link Profiler.start} call exists for `label`.
75
+ *
76
+ * @param label - Name of the measurement to complete.
77
+ *
78
+ * @example
79
+ * ```typescript
80
+ * profiler.start('render');
81
+ * render();
82
+ * profiler.end('render');
83
+ * ```
84
+ */
26
85
  end(label) {
27
86
  // Compatible con ES2020: usar slice().reverse() en lugar de findLast
28
87
  const entry = this.stack
@@ -1 +1 @@
1
- {"version":3,"file":"Profiler.js","sourceRoot":"","sources":["../../../src/utils/core/Profiler.ts"],"names":[],"mappings":"AAAA,MAAM,OAAO,QAAQ;IAKjB,YAAY,SAAkB;QAJtB;;;;mBAA4C,EAAE;WAAC;QAC/C;;;;mBAAkD,EAAE;WAAC;QACrD;;;;;WAAmB;QAGvB,IAAI,CAAC,SAAS,GAAG,SAAS,CAAC;IAC/B,CAAC;IAED,KAAK,CAAC,KAAa;QACf,IAAI,CAAC,KAAK,CAAC,IAAI,CAAC,EAAE,KAAK,EAAE,KAAK,EAAE,WAAW,CAAC,GAAG,EAAE,EAAE,CAAC,CAAC;IACzD,CAAC;IAED,GAAG,CAAC,KAAa;QACb,qEAAqE;QACrE,MAAM,KAAK,GAAG,IAAI,CAAC,KAAK;aACnB,KAAK,EAAE;aACP,OAAO,EAAE;aACT,IAAI,CAAC,CAAC,CAAmC,EAAE,EAAE,CAAC,CAAC,CAAC,KAAK,KAAK,KAAK,CAAC,CAAC;QACtE,IAAI,CAAC,KAAK;YAAE,OAAO;QACnB,MAAM,QAAQ,GAAG,WAAW,CAAC,GAAG,EAAE,GAAG,KAAK,CAAC,KAAK,CAAC;QACjD,MAAM,GAAG,GAAG,IAAI,CAAC,SAAS,IAAI,UAAU,CAAC;QACzC,IAAI,CAAC,IAAI,CAAC,OAAO,CAAC,GAAG,CAAC,EAAE,CAAC;YACrB,IAAI,CAAC,OAAO,CAAC,GAAG,CAAC,GAAG,EAAE,CAAC;QAC3B,CAAC;QACD,IAAI,CAAC,OAAO,CAAC,GAAG,CAAC,CAAC,KAAK,CAAC,GAAG,QAAQ,CAAC;IACxC,CAAC;IAED,OAAO;QACH,mFAAmF;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,CAA0B;gBAE3C,MAAM,GAAE,iBAAsB;IAO1C;;OAEG;IACH,SAAS,CAAC,GAAG,EAAE,MAAM,GAAG,OAAO;IAwB/B;;OAEG;IACH,QAAQ,CAAC,GAAG,EAAE,MAAM,GAAG,gBAAgB;IAgCvC;;OAEG;IACH,KAAK,CAAC,GAAG,EAAE,MAAM,GAAG,IAAI;IAKxB;;OAEG;IACH,QAAQ,IAAI,IAAI;IAIhB;;OAEG;IACG,gBAAgB,CAAC,GAAG,EAAE,MAAM,GAAG,OAAO,CAAC,IAAI,CAAC;CAQrD;AAED;;;GAGG;AACH,qBAAa,wBAAwB;IACjC,OAAO,CAAC,QAAQ,CAAoC;IACpD,OAAO,CAAC,QAAQ,CAAC,WAAW,CAAS;IACrC,OAAO,CAAC,QAAQ,CAAC,QAAQ,CAAS;IAClC,OAAO,CAAC,QAAQ,CAAC,YAAY,CAA0B;gBAE3C,MAAM,GAAE,iBAAsB;IAO1C;;OAEG;IACH,SAAS,CAAC,GAAG,EAAE,MAAM,GAAG,OAAO;IAuB/B;;OAEG;IACH,QAAQ,CAAC,GAAG,EAAE,MAAM,GAAG,gBAAgB;IAuBvC;;OAEG;IACH,KAAK,CAAC,GAAG,EAAE,MAAM,GAAG,IAAI;IAKxB;;OAEG;IACH,QAAQ,IAAI,IAAI;IAIhB;;OAEG;IACG,gBAAgB,CAAC,GAAG,EAAE,MAAM,GAAG,OAAO,CAAC,IAAI,CAAC;CAQrD"}
@@ -101,6 +101,7 @@ export class RateLimiter {
101
101
  async waitForAllowance(url) {
102
102
  while (!this.isAllowed(url)) {
103
103
  const stats = this.getStats(url);
104
+ /* v8 ignore next */
104
105
  const waitTime = Math.min(stats.retryAfter ?? 1, 1) * 1000;
105
106
  await new Promise((resolve) => setTimeout(resolve, waitTime));
106
107
  }
@@ -202,6 +203,7 @@ export class SlidingWindowRateLimiter {
202
203
  async waitForAllowance(url) {
203
204
  while (!this.isAllowed(url)) {
204
205
  const stats = this.getStats(url);
206
+ /* v8 ignore next */
205
207
  const waitTime = Math.min(stats.retryAfter ?? 1, 1) * 1000;
206
208
  await new Promise((resolve) => setTimeout(resolve, waitTime));
207
209
  }