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
+6 -6
View File
@@ -566,7 +566,7 @@ export class Summary implements BaseMetric {
* Metrics registry
*/
export class MetricsRegistry {
private metrics: Map<string, Counter | Gauge | Histogram | Summary> = new Map()
private metricsMap: Map<string, Counter | Gauge | Histogram | Summary> = new Map()
private prefix: string
private defaultLabels: Labels
@@ -580,7 +580,7 @@ export class MetricsRegistry {
*/
register<T extends Counter | Gauge | Histogram | Summary>(metric: T): T {
const fullName = this.prefix ? `${this.prefix}_${metric.name}` : metric.name
this.metrics.set(fullName, metric)
this.metricsMap.set(fullName, metric)
return metric
}
@@ -589,7 +589,7 @@ export class MetricsRegistry {
*/
get(name: string): Counter | Gauge | Histogram | Summary | undefined {
const fullName = this.prefix ? `${this.prefix}_${name}` : name
return this.metrics.get(fullName)
return this.metricsMap.get(fullName)
}
/**
@@ -597,14 +597,14 @@ export class MetricsRegistry {
*/
remove(name: string): boolean {
const fullName = this.prefix ? `${this.prefix}_${name}` : name
return this.metrics.delete(fullName)
return this.metricsMap.delete(fullName)
}
/**
* Reset all metrics
*/
resetAll(): void {
for (const metric of this.metrics.values()) {
for (const metric of this.metricsMap.values()) {
metric.reset()
}
}
@@ -615,7 +615,7 @@ export class MetricsRegistry {
async metrics(): Promise<string> {
const lines: string[] = []
for (const [name, metric] of this.metrics) {
for (const [name, metric] of this.metricsMap) {
lines.push(`# HELP ${name} ${metric.help}`)
lines.push(`# TYPE ${name} ${metric.type}`)