@lgriffin/esi.ts 10.2.0 → 10.2.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/CHANGELOG.md +16 -0
- package/dist/{chunk-D5L5HZVF.mjs → chunk-4W66ONJI.mjs} +2 -6
- package/dist/chunk-4W66ONJI.mjs.map +1 -0
- package/dist/{chunk-XIB2OXEZ.js → chunk-N3B65VLB.js} +2 -6
- package/dist/chunk-N3B65VLB.js.map +1 -0
- package/dist/core/constants.d.ts +2 -2
- package/dist/core/logger/resolveLogger.d.ts +3 -3
- package/dist/core/logger/resolveLogger.d.ts.map +1 -1
- package/dist/core/pagination/AsyncPaginationIterator.d.ts.map +1 -1
- package/dist/core/pagination/CursorPaginationHandler.d.ts.map +1 -1
- package/dist/core/util/concurrency.d.ts.map +1 -1
- package/dist/errors.js +2 -2
- package/dist/errors.mjs +1 -1
- package/dist/index.js +92 -93
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +3 -4
- package/dist/index.mjs.map +1 -1
- package/dist/testing/index.js +2 -2
- package/dist/testing/index.mjs +1 -1
- package/package.json +1 -1
- package/dist/chunk-D5L5HZVF.mjs.map +0 -1
- package/dist/chunk-XIB2OXEZ.js.map +0 -1
package/dist/testing/index.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
"use strict";Object.defineProperty(exports, "__esModule", {value: true}); function _optionalChain(ops) { let lastAccessLHS = undefined; let value = ops[0]; let i = 1; while (i < ops.length) { const op = ops[i]; const fn = ops[i + 1]; i += 2; if ((op === 'optionalAccess' || op === 'optionalCall') && value == null) { return undefined; } if (op === 'access' || op === 'optionalAccess') { lastAccessLHS = value; value = fn(value); } else if (op === 'call' || op === 'optionalCall') { value = fn((...args) => value.call(lastAccessLHS, ...args)); lastAccessLHS = undefined; } } return value; }
|
|
2
2
|
|
|
3
|
-
var
|
|
3
|
+
var _chunkN3B65VLBjs = require('../chunk-N3B65VLB.js');
|
|
4
4
|
require('../chunk-PZ5AY32C.js');
|
|
5
5
|
|
|
6
6
|
// src/testing/TestDataFactory.ts
|
|
@@ -733,7 +733,7 @@ var TestDataFactory = class {
|
|
|
733
733
|
500: "Internal server error",
|
|
734
734
|
503: "Service unavailable"
|
|
735
735
|
};
|
|
736
|
-
return new (0,
|
|
736
|
+
return new (0, _chunkN3B65VLBjs.EsiError)(
|
|
737
737
|
statusCode,
|
|
738
738
|
// eslint-disable-next-line security/detect-object-injection
|
|
739
739
|
message || defaultMessages[statusCode] || "Unknown error"
|
package/dist/testing/index.mjs
CHANGED
package/package.json
CHANGED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/core/logger/DefaultLogger.ts","../src/core/logger/loggerUtil.ts","../src/core/logger/resolveLogger.ts","../src/core/logger/clientLog.ts","../src/core/circuitBreaker/CircuitBreaker.ts","../src/core/util/error.ts"],"sourcesContent":["import pino from 'pino';\nimport type { ILogger, LogContext } from './ILogger';\n\n/**\n * The default `ILogger` implementation — a thin wrapper around pino.\n *\n * Level resolution (highest precedence first):\n * 1. `level` passed to `createDefaultLogger` (e.g. from\n * `EsiClientConfig.logLevel`).\n * 2. The `ESI_LOG_LEVEL` environment variable.\n * 3. `'warn'` (library default — quiet unless the app opts in).\n *\n * The logger writes to `process.stdout` and can be swapped entirely via\n * `EsiClientConfig.logger` or the global `setLogger()` fallback.\n */\nexport type LogLevel = 'fatal' | 'error' | 'warn' | 'info' | 'debug' | 'trace';\n\nexport function createDefaultLogger(level?: string): ILogger {\n const resolved = level || process.env.ESI_LOG_LEVEL || 'warn';\n const pinoLogger = pino({ level: resolved });\n return toPinoLogger(pinoLogger);\n}\n\n/**\n * Adapt any pino-compatible logger (pino, pino-http child, custom sink) to the\n * `ILogger` contract. Context objects are spread onto the log event so they\n * appear as structured fields rather than being stringified into the message.\n */\nexport function toPinoLogger(p: {\n fatal: (...a: unknown[]) => void;\n error: (...a: unknown[]) => void;\n warn: (...a: unknown[]) => void;\n info: (...a: unknown[]) => void;\n debug: (...a: unknown[]) => void;\n trace: (...a: unknown[]) => void;\n}): ILogger {\n // Call through the sink object so pino methods keep their `this` binding.\n const emit =\n (level: LogLevel) =>\n (message: string, context?: LogContext): void =>\n context ? p[level](context, message) : p[level](message);\n return {\n fatal: emit('fatal'),\n error: emit('error'),\n warn: emit('warn'),\n info: emit('info'),\n debug: emit('debug'),\n trace: emit('trace'),\n };\n}\n\n/** Backwards-compatible default instance (level from `ESI_LOG_LEVEL`). */\nexport const defaultLogger: ILogger = createDefaultLogger();\n","import type { ILogger, LogContext } from './ILogger';\nimport { defaultLogger } from './DefaultLogger';\n\nexport type { ILogger, LogContext } from './ILogger';\n\n/**\n * Global logger fallback.\n *\n * The request pipeline reads the *per-client* logger first and only falls\n * back to this global when a client has none (e.g. the raw factory\n * `EsiApiFactory` clients, or unit tests that call pipeline modules\n * directly). Production apps can rely on the per-client logger from\n * `EsiClientConfig.logger`; this global exists for backwards compatibility\n * and for apps that want one shared logger across all clients.\n */\nlet activeLogger: ILogger = defaultLogger;\n\nexport const setLogger = (customLogger: ILogger): void => {\n activeLogger = customLogger;\n};\n\nexport const getLogger = (): ILogger => activeLogger;\n\nconst ctx = (context?: LogContext): LogContext | undefined =>\n context && Object.keys(context).length > 0 ? context : undefined;\n\nexport const logFatal = (message: string, context?: LogContext): void => {\n activeLogger.fatal(message, ctx(context));\n};\n\nexport const logError = (message: string, context?: LogContext): void => {\n activeLogger.error(message, ctx(context));\n};\n\nexport const logWarn = (message: string, context?: LogContext): void => {\n activeLogger.warn(message, ctx(context));\n};\n\nexport const logInfo = (message: string, context?: LogContext): void => {\n activeLogger.info(message, ctx(context));\n};\n\nexport const logDebug = (message: string, context?: LogContext): void => {\n activeLogger.debug(message, ctx(context));\n};\n\nexport const logTrace = (message: string, context?: LogContext): void => {\n activeLogger.trace(message, ctx(context));\n};\n","import type { ILogger } from './ILogger';\nimport { defaultLogger } from './DefaultLogger';\nimport { getLogger } from './loggerUtil';\n\n/**\n * Resolve the logger for a given API client: per-client logger first,\n * global (via `setLogger`) if a non-default one was installed, then the\n * built-in pino default.\n */\nexport function resolveLogger(\n client: { getLogger?: () => ILogger | null } | null | undefined,\n): ILogger {\n const perClient = client?.getLogger?.();\n if (perClient) return perClient;\n const global = getLogger();\n if (global !== defaultLogger) return global;\n return defaultLogger;\n}\n","import type { ApiClient } from '../ApiClient';\nimport type { LogContext } from './ILogger';\nimport { resolveLogger } from './resolveLogger';\n\ntype Level = 'fatal' | 'error' | 'warn' | 'info' | 'debug' | 'trace';\n\ntype Emit = (\n client: ApiClient | null | undefined,\n message: string,\n context?: LogContext,\n) => void;\n\nconst emit =\n (level: Level): Emit =>\n (client, message, context) => {\n resolveLogger(client)[level](\n message,\n context && Object.keys(context).length > 0 ? context : undefined,\n );\n };\n\nexport const logFatal: Emit = emit('fatal');\nexport const logError: Emit = emit('error');\nexport const logWarn: Emit = emit('warn');\nexport const logInfo: Emit = emit('info');\nexport const logDebug: Emit = emit('debug');\nexport const logTrace: Emit = emit('trace');\n","import { ApiClient } from '../ApiClient';\nimport { logWarn, logInfo } from '../logger/clientLog';\nimport { ICircuitBreaker } from './ICircuitBreaker';\n\nexport type CircuitState = 'closed' | 'open' | 'half-open';\n\nexport interface CircuitBreakerConfig {\n failureThreshold?: number;\n resetTimeoutMs?: number;\n halfOpenMaxAttempts?: number;\n staleThresholdMs?: number;\n /** 'resolved' (default, current behavior) | 'template' (group by endpoint template path) */\n keyStrategy?: 'resolved' | 'template';\n /** Interval in ms for automatic cleanup of stale circuits. 0 or undefined disables. Recommended value: staleThresholdMs. */\n cleanupIntervalMs?: number;\n}\n\ninterface CircuitRecord {\n state: CircuitState;\n failures: number;\n lastFailureTime: number;\n halfOpenAttempts: number;\n}\n\nexport class CircuitBreaker implements ICircuitBreaker {\n private circuits: Map<string, CircuitRecord> = new Map();\n private readonly failureThreshold: number;\n private readonly resetTimeoutMs: number;\n private readonly halfOpenMaxAttempts: number;\n private readonly staleThresholdMs: number;\n private readonly keyStrategy: 'resolved' | 'template';\n private cleanupTimer: ReturnType<typeof setInterval> | null = null;\n private client: ApiClient | null = null;\n\n setClient(client: ApiClient | null): void {\n this.client = client;\n }\n\n constructor(config: CircuitBreakerConfig = {}) {\n this.failureThreshold = config.failureThreshold ?? 5;\n this.resetTimeoutMs = config.resetTimeoutMs ?? 30_000;\n this.halfOpenMaxAttempts = config.halfOpenMaxAttempts ?? 1;\n this.staleThresholdMs = config.staleThresholdMs ?? 3_600_000;\n this.keyStrategy = config.keyStrategy ?? 'resolved';\n\n const cleanupIntervalMs = config.cleanupIntervalMs;\n if (cleanupIntervalMs !== undefined && cleanupIntervalMs > 0) {\n this.startCleanupTimer(cleanupIntervalMs);\n }\n }\n\n private getKey(endpoint: string): string {\n return endpoint.split('?')[0]!;\n }\n\n private getOrCreate(key: string): CircuitRecord {\n let record = this.circuits.get(key);\n if (!record) {\n record = {\n state: 'closed',\n failures: 0,\n lastFailureTime: 0,\n halfOpenAttempts: 0,\n };\n this.circuits.set(key, record);\n }\n return record;\n }\n\n checkCircuit(endpoint: string): void {\n const key = this.getKey(endpoint);\n const record = this.getOrCreate(key);\n\n if (record.state === 'closed') return;\n\n if (record.state === 'open') {\n const elapsed = Date.now() - record.lastFailureTime;\n if (elapsed >= this.resetTimeoutMs) {\n record.state = 'half-open';\n // This call is the first probe, so it counts towards halfOpenMaxAttempts.\n record.halfOpenAttempts = 1;\n logInfo(\n this.client,\n `Circuit half-open for ${key}, allowing probe request`,\n { key },\n );\n return;\n }\n const remainingMs = this.resetTimeoutMs - elapsed;\n throw new CircuitOpenError(key, record.failures, remainingMs);\n }\n\n if (record.state === 'half-open') {\n if (record.halfOpenAttempts >= this.halfOpenMaxAttempts) {\n throw new CircuitOpenError(key, record.failures, this.resetTimeoutMs);\n }\n record.halfOpenAttempts++;\n }\n }\n\n recordSuccess(endpoint: string): void {\n const key = this.getKey(endpoint);\n const record = this.circuits.get(key);\n if (!record) return;\n\n // A success while open comes from a call admitted before the circuit\n // opened. Only a half-open probe may close the circuit.\n if (record.state === 'open') return;\n\n if (record.state === 'half-open') {\n logInfo(this.client, `Circuit closed for ${key} after successful probe`, {\n key,\n });\n }\n\n record.state = 'closed';\n record.failures = 0;\n record.halfOpenAttempts = 0;\n }\n\n recordFailure(endpoint: string, statusCode: number): void {\n // statusCode 0 = network/timeout; 420/429 = rate limited; >=500 = server errors\n if (\n statusCode !== 0 &&\n statusCode < 500 &&\n statusCode !== 420 &&\n statusCode !== 429\n ) {\n return;\n }\n\n const key = this.getKey(endpoint);\n const record = this.getOrCreate(key);\n\n record.failures++;\n record.lastFailureTime = Date.now();\n\n if (record.state === 'half-open') {\n record.state = 'open';\n logWarn(\n this.client,\n `Circuit re-opened for ${key} after failed probe (${record.failures} failures)`,\n { key, failures: record.failures },\n );\n return;\n }\n\n if (record.failures >= this.failureThreshold) {\n record.state = 'open';\n logWarn(\n this.client,\n `Circuit opened for ${key} after ${record.failures} consecutive failures`,\n { key, failures: record.failures },\n );\n }\n }\n\n getState(endpoint: string): CircuitState {\n const key = this.getKey(endpoint);\n const record = this.circuits.get(key);\n if (!record) return 'closed';\n\n if (record.state === 'open') {\n const elapsed = Date.now() - record.lastFailureTime;\n if (elapsed >= this.resetTimeoutMs) {\n return 'half-open';\n }\n }\n\n return record.state;\n }\n\n getStats(): {\n totalCircuits: number;\n openCircuits: number;\n circuits: Record<string, { state: CircuitState; failures: number }>;\n } {\n const circuits: Record<string, { state: CircuitState; failures: number }> =\n {};\n let openCircuits = 0;\n\n for (const [key, record] of this.circuits.entries()) {\n const state = this.getState(key);\n // eslint-disable-next-line security/detect-object-injection\n circuits[key] = { state, failures: record.failures };\n if (state === 'open') openCircuits++;\n }\n\n return {\n totalCircuits: this.circuits.size,\n openCircuits,\n circuits,\n };\n }\n\n reset(endpoint?: string): void {\n if (endpoint) {\n this.circuits.delete(this.getKey(endpoint));\n } else {\n this.circuits.clear();\n }\n }\n\n cleanup(): number {\n const now = Date.now();\n let cleaned = 0;\n for (const [key, record] of this.circuits.entries()) {\n if (\n record.state === 'closed' &&\n record.failures === 0 &&\n record.lastFailureTime > 0 &&\n now - record.lastFailureTime > this.staleThresholdMs\n ) {\n this.circuits.delete(key);\n cleaned++;\n }\n }\n if (cleaned > 0) {\n logInfo(\n this.client,\n `Circuit breaker cleanup: removed ${cleaned} stale circuits`,\n {\n cleaned,\n },\n );\n }\n return cleaned;\n }\n\n getKeyStrategy(): 'resolved' | 'template' {\n return this.keyStrategy;\n }\n\n destroy(): void {\n if (this.cleanupTimer) {\n clearInterval(this.cleanupTimer);\n this.cleanupTimer = null;\n }\n this.circuits.clear();\n }\n\n shutdown(): void {\n this.destroy();\n }\n\n private startCleanupTimer(intervalMs: number): void {\n this.cleanupTimer = setInterval(() => {\n this.cleanup();\n }, intervalMs);\n // Don't prevent process exit (important for test runners and CLI tools)\n this.cleanupTimer.unref();\n }\n}\n\nexport class CircuitOpenError extends Error {\n readonly endpoint: string;\n readonly failures: number;\n readonly retryAfterMs: number;\n\n constructor(endpoint: string, failures: number, retryAfterMs: number) {\n super(\n `Circuit breaker open for ${endpoint} after ${failures} failures (retry after ${Math.ceil(retryAfterMs / 1000)}s)`,\n );\n this.name = 'CircuitOpenError';\n this.endpoint = endpoint;\n this.failures = failures;\n this.retryAfterMs = retryAfterMs;\n }\n}\n","const SENSITIVE_PARAMS = [\n 'token',\n 'access_token',\n 'api_key',\n 'refresh_token',\n 'client_secret',\n 'code',\n 'key',\n 'secret',\n 'auth',\n 'password',\n 'bearer',\n];\n\nexport function sanitizeUrl(url?: string): string | undefined {\n if (!url) return url;\n try {\n const parsed = new URL(url);\n for (const param of SENSITIVE_PARAMS) {\n if (parsed.searchParams.has(param)) {\n parsed.searchParams.set(param, '[REDACTED]');\n }\n }\n return parsed.toString();\n } catch {\n const qIndex = url.indexOf('?');\n return qIndex >= 0 ? url.substring(0, qIndex) + '?[params-redacted]' : url;\n }\n}\n\nexport class EsiError extends Error {\n public readonly url?: string;\n\n constructor(\n public readonly statusCode: number,\n message: string,\n url?: string,\n public readonly requestId?: string,\n ) {\n super(message);\n this.name = 'EsiError';\n this.url = sanitizeUrl(url);\n }\n\n isRateLimited(): boolean {\n return this.statusCode === 420 || this.statusCode === 429;\n }\n\n isNotFound(): boolean {\n return this.statusCode === 404;\n }\n\n isUnauthorized(): boolean {\n return this.statusCode === 401;\n }\n\n isForbidden(): boolean {\n return this.statusCode === 403;\n }\n\n isServerError(): boolean {\n return this.statusCode >= 500;\n }\n\n isTimeout(): boolean {\n return this.statusCode === 0;\n }\n\n get retryable(): boolean {\n return (\n this.statusCode === 0 ||\n this.statusCode === 420 ||\n this.statusCode === 429 ||\n this.statusCode === 502 ||\n this.statusCode === 503 ||\n this.statusCode === 504\n );\n }\n}\n\nexport function isEsiError(error: unknown): error is EsiError {\n return error instanceof EsiError;\n}\n\nexport function isRateLimited(error: unknown): error is EsiError {\n return error instanceof EsiError && error.isRateLimited();\n}\n\nexport function isNotFound(error: unknown): error is EsiError {\n return error instanceof EsiError && error.isNotFound();\n}\n\nexport function isUnauthorized(error: unknown): error is EsiError {\n return error instanceof EsiError && error.isUnauthorized();\n}\n\nexport function isForbidden(error: unknown): error is EsiError {\n return error instanceof EsiError && error.isForbidden();\n}\n\nexport function isServerError(error: unknown): error is EsiError {\n return error instanceof EsiError && error.isServerError();\n}\n\nexport class TimeoutError extends EsiError {\n constructor(\n public readonly timeoutMs: number,\n url?: string,\n requestId?: string,\n ) {\n super(0, `Request timed out after ${timeoutMs}ms`, url, requestId);\n this.name = 'TimeoutError';\n }\n}\n\nexport function isTimeout(error: unknown): error is TimeoutError {\n return error instanceof TimeoutError;\n}\n\nexport function isRetryable(error: unknown): error is EsiError {\n return error instanceof EsiError && error.retryable;\n}\n\n// Re-export CircuitOpenError for the type guard — avoid forcing consumers\n// to import from the circuitBreaker subpath just for error checking.\nimport { CircuitOpenError } from '../circuitBreaker/CircuitBreaker';\n\nexport function isCircuitOpen(error: unknown): error is CircuitOpenError {\n return error instanceof CircuitOpenError;\n}\n\nexport const buildError = (\n message: string,\n type: string = 'ERROR',\n url?: string,\n): Error => {\n const error = new Error(`[${type}] ${message}`);\n if (url) {\n (error as Error & { url: string }).url = url;\n }\n return error;\n};\n\nexport type ValidationDirection = 'request' | 'response';\n\nexport class EsiValidationError extends EsiError {\n public readonly validationError: unknown;\n public readonly direction: ValidationDirection;\n\n constructor(\n url: string,\n zodError: unknown,\n requestId?: string,\n direction: ValidationDirection = 'response',\n ) {\n const safeUrl = sanitizeUrl(url) ?? url;\n const label = direction === 'request' ? 'Request body' : 'Response';\n super(0, `${label} validation failed for ${safeUrl}`, url, requestId);\n this.name = 'EsiValidationError';\n this.validationError = zodError;\n this.direction = direction;\n }\n}\n\nexport function isValidationError(error: unknown): error is EsiValidationError {\n return error instanceof EsiValidationError;\n}\n"],"mappings":";AAAA,OAAO,UAAU;AAiBV,SAAS,oBAAoB,OAAyB;AAC3D,QAAM,WAAW,SAAS,QAAQ,IAAI,iBAAiB;AACvD,QAAM,aAAa,KAAK,EAAE,OAAO,SAAS,CAAC;AAC3C,SAAO,aAAa,UAAU;AAChC;AAOO,SAAS,aAAa,GAOjB;AAEV,QAAMA,QACJ,CAAC,UACD,CAAC,SAAiB,YAChB,UAAU,EAAE,KAAK,EAAE,SAAS,OAAO,IAAI,EAAE,KAAK,EAAE,OAAO;AAC3D,SAAO;AAAA,IACL,OAAOA,MAAK,OAAO;AAAA,IACnB,OAAOA,MAAK,OAAO;AAAA,IACnB,MAAMA,MAAK,MAAM;AAAA,IACjB,MAAMA,MAAK,MAAM;AAAA,IACjB,OAAOA,MAAK,OAAO;AAAA,IACnB,OAAOA,MAAK,OAAO;AAAA,EACrB;AACF;AAGO,IAAM,gBAAyB,oBAAoB;;;ACrC1D,IAAI,eAAwB;AAErB,IAAM,YAAY,CAAC,iBAAgC;AACxD,iBAAe;AACjB;AAEO,IAAM,YAAY,MAAe;AAExC,IAAM,MAAM,CAAC,YACX,WAAW,OAAO,KAAK,OAAO,EAAE,SAAS,IAAI,U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OAAmC;AAC7D,SAAO,iBAAiB,YAAY,MAAM;AAC5C;AAMO,SAAS,cAAc,OAA2C;AACvE,SAAO,iBAAiB;AAC1B;AAEO,IAAM,aAAa,CACxB,SACA,OAAe,SACf,QACU;AACV,QAAM,QAAQ,IAAI,MAAM,IAAI,IAAI,KAAK,OAAO,EAAE;AAC9C,MAAI,KAAK;AACP,IAAC,MAAkC,MAAM;AAAA,EAC3C;AACA,SAAO;AACT;AAIO,IAAM,qBAAN,cAAiC,SAAS;AAAA,EAC/B;AAAA,EACA;AAAA,EAEhB,YACE,KACA,UACA,WACA,YAAiC,YACjC;AACA,UAAM,UAAU,YAAY,GAAG,KAAK;AACpC,UAAM,QAAQ,cAAc,YAAY,iBAAiB;AACzD,UAAM,GAAG,GAAG,KAAK,0BAA0B,OAAO,IAAI,KAAK,SAAS;AACpE,SAAK,OAAO;AACZ,SAAK,kBAAkB;AACvB,SAAK,YAAY;AAAA,EACnB;AACF;AAEO,SAAS,kBAAkB,OAA6C;AAC7E,SAAO,iBAAiB;AAC1B;","names":["emit","logFatal","logError","logWarn","logInfo","logDebug","logTrace","logInfo","logWarn"]}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"sources":["/home/runner/work/ESI.ts/ESI.ts/dist/chunk-XIB2OXEZ.js","../src/core/logger/DefaultLogger.ts","../src/core/logger/loggerUtil.ts","../src/core/logger/resolveLogger.ts","../src/core/logger/clientLog.ts","../src/core/circuitBreaker/CircuitBreaker.ts","../src/core/util/error.ts"],"names":["emit","logFatal","logError","logWarn","logInfo","logDebug","logTrace"],"mappings":"AAAA;ACAA,wEAAiB;AAiBV,SAAS,mBAAA,CAAoB,KAAA,EAAyB;AAC3D,EAAA,MAAM,SAAA,EAAW,MAAA,GAAS,OAAA,CAAQ,GAAA,CAAI,cAAA,GAAiB,MAAA;AACvD,EAAA,MAAM,WAAA,EAAa,4BAAA,EAAO,KAAA,EAAO,SAAS,CAAC,CAAA;AAC3C,EAAA,OAAO,YAAA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AAA,QAA2B,SAAS;AAAA,EACzC,WAAA,CACkB,SAAA,EAChB,GAAA,EACA,SAAA,EACA;AACA,IAAA,KAAA,CAAM,CAAA,EAAG,CAAA,wBAAA,EAA2B,SAAS,CAAA,EAAA,CAAA,EAAM,GAAA,EAAK,SAAS,CAAA;AAJjD,IAAA,IAAA,CAAA,UAAA,EAAA,SAAA;AAKhB,IAAA,IAAA,CAAK,KAAA,EAAO,cAAA;AAAA,EACd;AAAA,EANkB;AAOpB,CAAA;AAEO,SAAS,SAAA,CAAU,KAAA,EAAuC;AAC/D,EAAA,OAAO,MAAA,WAAiB,YAAA;AAC1B;AAEO,SAAS,WAAA,CAAY,KAAA,EAAmC;AAC7D,EAAA,OAAO,MAAA,WAAiB,SAAA,GAAY,KAAA,CAAM,SAAA;AAC5C;AAMO,SAAS,aAAA,CAAc,KAAA,EAA2C;AACvE,EAAA,OAAO,MAAA,WAAiB,gBAAA;AAC1B;AAEO,IAAM,WAAA,EAAa,CACxB,OAAA,EACA,KAAA,EAAe,OAAA,EACf,GAAA,EAAA,GACU;AACV,EAAA,MAAM,MAAA,EAAQ,IAAI,KAAA,CAAM,CAAA,CAAA,EAAI,IAAI,CAAA,EAAA,EAAK,OAAO,CAAA,CAAA;AACnC,EAAA;AACkC,IAAA;AAC3C,EAAA;AACO,EAAA;AACT;AAIwC;AACtB,EAAA;AACA,EAAA;AAMd,EAAA;AAEoC,IAAA;AACI,IAAA;AACG,IAAA;AAC/B,IAAA;AACW,IAAA;AACN,IAAA;AACnB,EAAA;AACF;AAE+E;AACrD,EAAA;AAC1B;ANwN+C;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA","file":"/home/runner/work/ESI.ts/ESI.ts/dist/chunk-XIB2OXEZ.js","sourcesContent":[null,"import pino from 'pino';\nimport type { ILogger, LogContext } from './ILogger';\n\n/**\n * The default `ILogger` implementation — a thin wrapper around pino.\n *\n * Level resolution (highest precedence first):\n * 1. `level` passed to `createDefaultLogger` (e.g. from\n * `EsiClientConfig.logLevel`).\n * 2. The `ESI_LOG_LEVEL` environment variable.\n * 3. `'warn'` (library default — quiet unless the app opts in).\n *\n * The logger writes to `process.stdout` and can be swapped entirely via\n * `EsiClientConfig.logger` or the global `setLogger()` fallback.\n */\nexport type LogLevel = 'fatal' | 'error' | 'warn' | 'info' | 'debug' | 'trace';\n\nexport function createDefaultLogger(level?: string): ILogger {\n const resolved = level || process.env.ESI_LOG_LEVEL || 'warn';\n const pinoLogger = pino({ level: resolved });\n return toPinoLogger(pinoLogger);\n}\n\n/**\n * Adapt any pino-compatible logger (pino, pino-http child, custom sink) to the\n * `ILogger` contract. Context objects are spread onto the log event so they\n * appear as structured fields rather than being stringified into the message.\n */\nexport function toPinoLogger(p: {\n fatal: (...a: unknown[]) => void;\n error: (...a: unknown[]) => void;\n warn: (...a: unknown[]) => void;\n info: (...a: unknown[]) => void;\n debug: (...a: unknown[]) => void;\n trace: (...a: unknown[]) => void;\n}): ILogger {\n // Call through the sink object so pino methods keep their `this` binding.\n const emit =\n (level: LogLevel) =>\n (message: string, context?: LogContext): void =>\n context ? p[level](context, message) : p[level](message);\n return {\n fatal: emit('fatal'),\n error: emit('error'),\n warn: emit('warn'),\n info: emit('info'),\n debug: emit('debug'),\n trace: emit('trace'),\n };\n}\n\n/** Backwards-compatible default instance (level from `ESI_LOG_LEVEL`). */\nexport const defaultLogger: ILogger = createDefaultLogger();\n","import type { ILogger, LogContext } from './ILogger';\nimport { defaultLogger } from './DefaultLogger';\n\nexport type { ILogger, LogContext } from './ILogger';\n\n/**\n * Global logger fallback.\n *\n * The request pipeline reads the *per-client* logger first and only falls\n * back to this global when a client has none (e.g. the raw factory\n * `EsiApiFactory` clients, or unit tests that call pipeline modules\n * directly). Production apps can rely on the per-client logger from\n * `EsiClientConfig.logger`; this global exists for backwards compatibility\n * and for apps that want one shared logger across all clients.\n */\nlet activeLogger: ILogger = defaultLogger;\n\nexport const setLogger = (customLogger: ILogger): void => {\n activeLogger = customLogger;\n};\n\nexport const getLogger = (): ILogger => activeLogger;\n\nconst ctx = (context?: LogContext): LogContext | undefined =>\n context && Object.keys(context).length > 0 ? context : undefined;\n\nexport const logFatal = (message: string, context?: LogContext): void => {\n activeLogger.fatal(message, ctx(context));\n};\n\nexport const logError = (message: string, context?: LogContext): void => {\n activeLogger.error(message, ctx(context));\n};\n\nexport const logWarn = (message: string, context?: LogContext): void => {\n activeLogger.warn(message, ctx(context));\n};\n\nexport const logInfo = (message: string, context?: LogContext): void => {\n activeLogger.info(message, ctx(context));\n};\n\nexport const logDebug = (message: string, context?: LogContext): void => {\n activeLogger.debug(message, ctx(context));\n};\n\nexport const logTrace = (message: string, context?: LogContext): void => {\n activeLogger.trace(message, ctx(context));\n};\n","import type { ILogger } from './ILogger';\nimport { defaultLogger } from './DefaultLogger';\nimport { getLogger } from './loggerUtil';\n\n/**\n * Resolve the logger for a given API client: per-client logger first,\n * global (via `setLogger`) if a non-default one was installed, then the\n * built-in pino default.\n */\nexport function resolveLogger(\n client: { getLogger?: () => ILogger | null } | null | undefined,\n): ILogger {\n const perClient = client?.getLogger?.();\n if (perClient) return perClient;\n const global = getLogger();\n if (global !== defaultLogger) return global;\n return defaultLogger;\n}\n","import type { ApiClient } from '../ApiClient';\nimport type { LogContext } from './ILogger';\nimport { resolveLogger } from './resolveLogger';\n\ntype Level = 'fatal' | 'error' | 'warn' | 'info' | 'debug' | 'trace';\n\ntype Emit = (\n client: ApiClient | null | undefined,\n message: string,\n context?: LogContext,\n) => void;\n\nconst emit =\n (level: Level): Emit =>\n (client, message, context) => {\n resolveLogger(client)[level](\n message,\n context && Object.keys(context).length > 0 ? context : undefined,\n );\n };\n\nexport const logFatal: Emit = emit('fatal');\nexport const logError: Emit = emit('error');\nexport const logWarn: Emit = emit('warn');\nexport const logInfo: Emit = emit('info');\nexport const logDebug: Emit = emit('debug');\nexport const logTrace: Emit = emit('trace');\n","import { ApiClient } from '../ApiClient';\nimport { logWarn, logInfo } from '../logger/clientLog';\nimport { ICircuitBreaker } from './ICircuitBreaker';\n\nexport type CircuitState = 'closed' | 'open' | 'half-open';\n\nexport interface CircuitBreakerConfig {\n failureThreshold?: number;\n resetTimeoutMs?: number;\n halfOpenMaxAttempts?: number;\n staleThresholdMs?: number;\n /** 'resolved' (default, current behavior) | 'template' (group by endpoint template path) */\n keyStrategy?: 'resolved' | 'template';\n /** Interval in ms for automatic cleanup of stale circuits. 0 or undefined disables. Recommended value: staleThresholdMs. */\n cleanupIntervalMs?: number;\n}\n\ninterface CircuitRecord {\n state: CircuitState;\n failures: number;\n lastFailureTime: number;\n halfOpenAttempts: number;\n}\n\nexport class CircuitBreaker implements ICircuitBreaker {\n private circuits: Map<string, CircuitRecord> = new Map();\n private readonly failureThreshold: number;\n private readonly resetTimeoutMs: number;\n private readonly halfOpenMaxAttempts: number;\n private readonly staleThresholdMs: number;\n private readonly keyStrategy: 'resolved' | 'template';\n private cleanupTimer: ReturnType<typeof setInterval> | null = null;\n private client: ApiClient | null = null;\n\n setClient(client: ApiClient | null): void {\n this.client = client;\n }\n\n constructor(config: CircuitBreakerConfig = {}) {\n this.failureThreshold = config.failureThreshold ?? 5;\n this.resetTimeoutMs = config.resetTimeoutMs ?? 30_000;\n this.halfOpenMaxAttempts = config.halfOpenMaxAttempts ?? 1;\n this.staleThresholdMs = config.staleThresholdMs ?? 3_600_000;\n this.keyStrategy = config.keyStrategy ?? 'resolved';\n\n const cleanupIntervalMs = config.cleanupIntervalMs;\n if (cleanupIntervalMs !== undefined && cleanupIntervalMs > 0) {\n this.startCleanupTimer(cleanupIntervalMs);\n }\n }\n\n private getKey(endpoint: string): string {\n return endpoint.split('?')[0]!;\n }\n\n private getOrCreate(key: string): CircuitRecord {\n let record = this.circuits.get(key);\n if (!record) {\n record = {\n state: 'closed',\n failures: 0,\n lastFailureTime: 0,\n halfOpenAttempts: 0,\n };\n this.circuits.set(key, record);\n }\n return record;\n }\n\n checkCircuit(endpoint: string): void {\n const key = this.getKey(endpoint);\n const record = this.getOrCreate(key);\n\n if (record.state === 'closed') return;\n\n if (record.state === 'open') {\n const elapsed = Date.now() - record.lastFailureTime;\n if (elapsed >= this.resetTimeoutMs) {\n record.state = 'half-open';\n // This call is the first probe, so it counts towards halfOpenMaxAttempts.\n record.halfOpenAttempts = 1;\n logInfo(\n this.client,\n `Circuit half-open for ${key}, allowing probe request`,\n { key },\n );\n return;\n }\n const remainingMs = this.resetTimeoutMs - elapsed;\n throw new CircuitOpenError(key, record.failures, remainingMs);\n }\n\n if (record.state === 'half-open') {\n if (record.halfOpenAttempts >= this.halfOpenMaxAttempts) {\n throw new CircuitOpenError(key, record.failures, this.resetTimeoutMs);\n }\n record.halfOpenAttempts++;\n }\n }\n\n recordSuccess(endpoint: string): void {\n const key = this.getKey(endpoint);\n const record = this.circuits.get(key);\n if (!record) return;\n\n // A success while open comes from a call admitted before the circuit\n // opened. Only a half-open probe may close the circuit.\n if (record.state === 'open') return;\n\n if (record.state === 'half-open') {\n logInfo(this.client, `Circuit closed for ${key} after successful probe`, {\n key,\n });\n }\n\n record.state = 'closed';\n record.failures = 0;\n record.halfOpenAttempts = 0;\n }\n\n recordFailure(endpoint: string, statusCode: number): void {\n // statusCode 0 = network/timeout; 420/429 = rate limited; >=500 = server errors\n if (\n statusCode !== 0 &&\n statusCode < 500 &&\n statusCode !== 420 &&\n statusCode !== 429\n ) {\n return;\n }\n\n const key = this.getKey(endpoint);\n const record = this.getOrCreate(key);\n\n record.failures++;\n record.lastFailureTime = Date.now();\n\n if (record.state === 'half-open') {\n record.state = 'open';\n logWarn(\n this.client,\n `Circuit re-opened for ${key} after failed probe (${record.failures} failures)`,\n { key, failures: record.failures },\n );\n return;\n }\n\n if (record.failures >= this.failureThreshold) {\n record.state = 'open';\n logWarn(\n this.client,\n `Circuit opened for ${key} after ${record.failures} consecutive failures`,\n { key, failures: record.failures },\n );\n }\n }\n\n getState(endpoint: string): CircuitState {\n const key = this.getKey(endpoint);\n const record = this.circuits.get(key);\n if (!record) return 'closed';\n\n if (record.state === 'open') {\n const elapsed = Date.now() - record.lastFailureTime;\n if (elapsed >= this.resetTimeoutMs) {\n return 'half-open';\n }\n }\n\n return record.state;\n }\n\n getStats(): {\n totalCircuits: number;\n openCircuits: number;\n circuits: Record<string, { state: CircuitState; failures: number }>;\n } {\n const circuits: Record<string, { state: CircuitState; failures: number }> =\n {};\n let openCircuits = 0;\n\n for (const [key, record] of this.circuits.entries()) {\n const state = this.getState(key);\n // eslint-disable-next-line security/detect-object-injection\n circuits[key] = { state, failures: record.failures };\n if (state === 'open') openCircuits++;\n }\n\n return {\n totalCircuits: this.circuits.size,\n openCircuits,\n circuits,\n };\n }\n\n reset(endpoint?: string): void {\n if (endpoint) {\n this.circuits.delete(this.getKey(endpoint));\n } else {\n this.circuits.clear();\n }\n }\n\n cleanup(): number {\n const now = Date.now();\n let cleaned = 0;\n for (const [key, record] of this.circuits.entries()) {\n if (\n record.state === 'closed' &&\n record.failures === 0 &&\n record.lastFailureTime > 0 &&\n now - record.lastFailureTime > this.staleThresholdMs\n ) {\n this.circuits.delete(key);\n cleaned++;\n }\n }\n if (cleaned > 0) {\n logInfo(\n this.client,\n `Circuit breaker cleanup: removed ${cleaned} stale circuits`,\n {\n cleaned,\n },\n );\n }\n return cleaned;\n }\n\n getKeyStrategy(): 'resolved' | 'template' {\n return this.keyStrategy;\n }\n\n destroy(): void {\n if (this.cleanupTimer) {\n clearInterval(this.cleanupTimer);\n this.cleanupTimer = null;\n }\n this.circuits.clear();\n }\n\n shutdown(): void {\n this.destroy();\n }\n\n private startCleanupTimer(intervalMs: number): void {\n this.cleanupTimer = setInterval(() => {\n this.cleanup();\n }, intervalMs);\n // Don't prevent process exit (important for test runners and CLI tools)\n this.cleanupTimer.unref();\n }\n}\n\nexport class CircuitOpenError extends Error {\n readonly endpoint: string;\n readonly failures: number;\n readonly retryAfterMs: number;\n\n constructor(endpoint: string, failures: number, retryAfterMs: number) {\n super(\n `Circuit breaker open for ${endpoint} after ${failures} failures (retry after ${Math.ceil(retryAfterMs / 1000)}s)`,\n );\n this.name = 'CircuitOpenError';\n this.endpoint = endpoint;\n this.failures = failures;\n this.retryAfterMs = retryAfterMs;\n }\n}\n","const SENSITIVE_PARAMS = [\n 'token',\n 'access_token',\n 'api_key',\n 'refresh_token',\n 'client_secret',\n 'code',\n 'key',\n 'secret',\n 'auth',\n 'password',\n 'bearer',\n];\n\nexport function sanitizeUrl(url?: string): string | undefined {\n if (!url) return url;\n try {\n const parsed = new URL(url);\n for (const param of SENSITIVE_PARAMS) {\n if (parsed.searchParams.has(param)) {\n parsed.searchParams.set(param, '[REDACTED]');\n }\n }\n return parsed.toString();\n } catch {\n const qIndex = url.indexOf('?');\n return qIndex >= 0 ? url.substring(0, qIndex) + '?[params-redacted]' : url;\n }\n}\n\nexport class EsiError extends Error {\n public readonly url?: string;\n\n constructor(\n public readonly statusCode: number,\n message: string,\n url?: string,\n public readonly requestId?: string,\n ) {\n super(message);\n this.name = 'EsiError';\n this.url = sanitizeUrl(url);\n }\n\n isRateLimited(): boolean {\n return this.statusCode === 420 || this.statusCode === 429;\n }\n\n isNotFound(): boolean {\n return this.statusCode === 404;\n }\n\n isUnauthorized(): boolean {\n return this.statusCode === 401;\n }\n\n isForbidden(): boolean {\n return this.statusCode === 403;\n }\n\n isServerError(): boolean {\n return this.statusCode >= 500;\n }\n\n isTimeout(): boolean {\n return this.statusCode === 0;\n }\n\n get retryable(): boolean {\n return (\n this.statusCode === 0 ||\n this.statusCode === 420 ||\n this.statusCode === 429 ||\n this.statusCode === 502 ||\n this.statusCode === 503 ||\n this.statusCode === 504\n );\n }\n}\n\nexport function isEsiError(error: unknown): error is EsiError {\n return error instanceof EsiError;\n}\n\nexport function isRateLimited(error: unknown): error is EsiError {\n return error instanceof EsiError && error.isRateLimited();\n}\n\nexport function isNotFound(error: unknown): error is EsiError {\n return error instanceof EsiError && error.isNotFound();\n}\n\nexport function isUnauthorized(error: unknown): error is EsiError {\n return error instanceof EsiError && error.isUnauthorized();\n}\n\nexport function isForbidden(error: unknown): error is EsiError {\n return error instanceof EsiError && error.isForbidden();\n}\n\nexport function isServerError(error: unknown): error is EsiError {\n return error instanceof EsiError && error.isServerError();\n}\n\nexport class TimeoutError extends EsiError {\n constructor(\n public readonly timeoutMs: number,\n url?: string,\n requestId?: string,\n ) {\n super(0, `Request timed out after ${timeoutMs}ms`, url, requestId);\n this.name = 'TimeoutError';\n }\n}\n\nexport function isTimeout(error: unknown): error is TimeoutError {\n return error instanceof TimeoutError;\n}\n\nexport function isRetryable(error: unknown): error is EsiError {\n return error instanceof EsiError && error.retryable;\n}\n\n// Re-export CircuitOpenError for the type guard — avoid forcing consumers\n// to import from the circuitBreaker subpath just for error checking.\nimport { CircuitOpenError } from '../circuitBreaker/CircuitBreaker';\n\nexport function isCircuitOpen(error: unknown): error is CircuitOpenError {\n return error instanceof CircuitOpenError;\n}\n\nexport const buildError = (\n message: string,\n type: string = 'ERROR',\n url?: string,\n): Error => {\n const error = new Error(`[${type}] ${message}`);\n if (url) {\n (error as Error & { url: string }).url = url;\n }\n return error;\n};\n\nexport type ValidationDirection = 'request' | 'response';\n\nexport class EsiValidationError extends EsiError {\n public readonly validationError: unknown;\n public readonly direction: ValidationDirection;\n\n constructor(\n url: string,\n zodError: unknown,\n requestId?: string,\n direction: ValidationDirection = 'response',\n ) {\n const safeUrl = sanitizeUrl(url) ?? url;\n const label = direction === 'request' ? 'Request body' : 'Response';\n super(0, `${label} validation failed for ${safeUrl}`, url, requestId);\n this.name = 'EsiValidationError';\n this.validationError = zodError;\n this.direction = direction;\n }\n}\n\nexport function isValidationError(error: unknown): error is EsiValidationError {\n return error instanceof EsiValidationError;\n}\n"]}
|