fix(utils): resolve TypeScript compilation errors

- baileys-event-stream.ts: Add null check for buffer item in priority insertion
- baileys-logger.ts: Handle 'silent' log level and fix JID sanitization
- cache-utils.ts: Fix type incompatibility in global cache with any type
- logger-adapter.ts: Add nullish coalescing for level mapping and fix console type cast
- prometheus-metrics.ts: Rename private 'metrics' property to 'metricsMap' to avoid conflict with method
- trace-context.ts: Store baggage header in variable before accessing to fix undefined check
This commit is contained in:
Claude
2026-01-20 02:05:14 +00:00
parent a934be9bc9
commit dd59a7fe65
6 changed files with 35 additions and 19 deletions
+11 -4
View File
@@ -331,8 +331,13 @@ export class BaileysLogger implements ILogger {
...(typeof sanitizedObj === 'object' && sanitizedObj !== null ? sanitizedObj : { value: sanitizedObj }),
}
// Structured log
this.structuredLogger[level](enrichedObj, msg)
// Structured log (skip if level is 'silent')
if (level !== 'silent') {
const logMethod = this.structuredLogger[level] as ((obj: unknown, msg?: string) => void) | undefined
if (logMethod) {
logMethod.call(this.structuredLogger, enrichedObj, msg)
}
}
// Event handler
if (this.config.eventHandler) {
@@ -429,8 +434,10 @@ export class BaileysLogger implements ILogger {
if (process.env.NODE_ENV === 'production') {
// In production, mask part of the number
const parts = jid.split('@')
if (parts.length === 2 && parts[0].length > 4) {
return `${parts[0].substring(0, 4)}****@${parts[1]}`
const localPart = parts[0]
const domain = parts[1]
if (parts.length === 2 && localPart && domain && localPart.length > 4) {
return `${localPart.substring(0, 4)}****@${domain}`
}
}
return jid