@codebit-programando-solucoes/codebit-web 1.1.11 → 1.1.17
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/api/api.d.ts +8 -5
- package/dist/index.cjs +6 -6
- package/package.json +1 -1
package/dist/api/api.d.ts
CHANGED
|
@@ -6,12 +6,12 @@ export interface RequestConfig {
|
|
|
6
6
|
headers?: Record<string, string>;
|
|
7
7
|
/** Request body data */
|
|
8
8
|
data?: any;
|
|
9
|
-
/** Request timeout in milliseconds */
|
|
9
|
+
/** Request timeout in milliseconds (defaults to 30000ms) */
|
|
10
10
|
timeout?: number;
|
|
11
11
|
/** AbortSignal for request cancellation */
|
|
12
12
|
signal?: AbortSignal;
|
|
13
13
|
/** Desired response format */
|
|
14
|
-
responseType?: 'json' | 'text' | 'blob' | 'arraybuffer';
|
|
14
|
+
responseType?: 'json' | 'text' | 'blob' | 'arraybuffer' | 'stream';
|
|
15
15
|
}
|
|
16
16
|
|
|
17
17
|
/** API response object. */
|
|
@@ -34,7 +34,7 @@ export interface StreamOptions extends RequestConfig {
|
|
|
34
34
|
export interface ApiConfig {
|
|
35
35
|
/** Base URL for API requests */
|
|
36
36
|
baseURL?: string;
|
|
37
|
-
/** Default timeout in milliseconds */
|
|
37
|
+
/** Default timeout in milliseconds (defaults to 30000ms) */
|
|
38
38
|
timeout?: number;
|
|
39
39
|
/** Default headers for all requests */
|
|
40
40
|
headers?: Record<string, string>;
|
|
@@ -104,7 +104,10 @@ export class ApiNetworkError extends Error {
|
|
|
104
104
|
constructor(error: Error);
|
|
105
105
|
}
|
|
106
106
|
|
|
107
|
-
/**
|
|
107
|
+
/**
|
|
108
|
+
* API object that mimics Axios behavior using fetch. Provides a familiar Axios-like interface while leveraging the modern fetch API under the hood. Includes features like
|
|
109
|
+
* request/response interceptors, automatic JSON parsing, and timeout handling.
|
|
110
|
+
*/
|
|
108
111
|
export declare const Api: {
|
|
109
112
|
/**
|
|
110
113
|
* Configures the API client globally with base URL, timeout, and default headers.
|
|
@@ -116,7 +119,7 @@ export declare const Api: {
|
|
|
116
119
|
* headers: { 'X-App-Version': '1.0.0' },
|
|
117
120
|
* });
|
|
118
121
|
*
|
|
119
|
-
* @param config - Configuration object
|
|
122
|
+
* @param config - Configuration object (timeout defaults to 30000ms)
|
|
120
123
|
*/
|
|
121
124
|
configure(config: ApiConfig): void;
|
|
122
125
|
|
package/dist/index.cjs
CHANGED
|
@@ -339,28 +339,28 @@ class Logger {
|
|
|
339
339
|
static setDefaultLevel(level) {
|
|
340
340
|
Logger._defaultLevel = level;
|
|
341
341
|
}
|
|
342
|
-
constructor(name, level =
|
|
342
|
+
constructor(name, level = null){
|
|
343
343
|
if (!name || 'string' != typeof name) throw new Error('Logger name must be a non-empty string.');
|
|
344
344
|
this.name = name;
|
|
345
345
|
this.level = level;
|
|
346
346
|
}
|
|
347
347
|
debug(...args) {
|
|
348
|
-
if (this.level <= Logger.LOG_LEVELS.DEBUG) this._safeLog('debug', ...args);
|
|
348
|
+
if ((this.level ?? Logger._defaultLevel) <= Logger.LOG_LEVELS.DEBUG) this._safeLog('debug', ...args);
|
|
349
349
|
}
|
|
350
350
|
error(...args) {
|
|
351
|
-
if (this.level <= Logger.LOG_LEVELS.ERROR) this._safeLog('error', ...args);
|
|
351
|
+
if ((this.level ?? Logger._defaultLevel) <= Logger.LOG_LEVELS.ERROR) this._safeLog('error', ...args);
|
|
352
352
|
}
|
|
353
353
|
info(...args) {
|
|
354
|
-
if (this.level <= Logger.LOG_LEVELS.INFO) this._safeLog('info', ...args);
|
|
354
|
+
if ((this.level ?? Logger._defaultLevel) <= Logger.LOG_LEVELS.INFO) this._safeLog('info', ...args);
|
|
355
355
|
}
|
|
356
356
|
log(...args) {
|
|
357
357
|
this._safeLog('log', ...args);
|
|
358
358
|
}
|
|
359
359
|
warn(...args) {
|
|
360
|
-
if (this.level <= Logger.LOG_LEVELS.WARN) this._safeLog('warn', ...args);
|
|
360
|
+
if ((this.level ?? Logger._defaultLevel) <= Logger.LOG_LEVELS.WARN) this._safeLog('warn', ...args);
|
|
361
361
|
}
|
|
362
362
|
trace(...args) {
|
|
363
|
-
if (this.level <= Logger.LOG_LEVELS.TRACE) this._safeLog('trace', ...args);
|
|
363
|
+
if ((this.level ?? Logger._defaultLevel) <= Logger.LOG_LEVELS.TRACE) this._safeLog('trace', ...args);
|
|
364
364
|
}
|
|
365
365
|
_safeLog(method, ...args) {
|
|
366
366
|
const consoleMethod = console[method] || console.log;
|