{
  "version": 3,
  "sources": ["../src/index.ts", "../src/checks/memory.ts", "../src/core/types.ts", "../src/checks/network.ts", "../src/checks/processor.ts", "../src/core/utils.ts", "../src/checks/uptime.ts", "../src/core/manager.ts"],
  "sourcesContent": ["export * from \"./checks/memory\";\nexport * from \"./checks/network\";\nexport * from \"./checks/processor\";\nexport * from \"./checks/uptime\";\nexport * from \"./core/manager\";\nexport * from \"./core/types\";\n", "import { filesize } from \"filesize\";\nimport { mem } from \"systeminformation\";\nimport { HealthCheck } from \"../core/types\";\nimport type { HealthStatus } from \"../core/types\";\n\nexport class MemoryHealthCheck extends HealthCheck<\"memory\"> {\n  constructor(\n    private readonly thresholds = { degraded: 0.15, unhealthy: 0.05 }\n  ) {\n    super(\"memory\", [\"liveness\", \"readiness\"]);\n  }\n\n  async run() {\n    const { free, total, used } = await mem();\n    const ratio = free / total;\n\n    let status: HealthStatus = \"ok\";\n    if (ratio < this.thresholds.unhealthy) status = \"unhealthy\";\n    else if (ratio < this.thresholds.degraded) status = \"degraded\";\n\n    return {\n      name: this.name,\n      type: this.types,\n      status,\n      metrics: {\n        total: filesize(total),\n        used: filesize(used),\n        free: filesize(free),\n        freePercent: `${(ratio * 100).toFixed(1)}%`,\n      },\n    };\n  }\n}\n", "export type HealthCheckType = \"liveness\" | \"readiness\";\n\nexport type HealthStatus = \"ok\" | \"degraded\" | \"unhealthy\";\n\nexport interface HealthCheckResult<TName extends string = string> {\n  name: TName;\n  type: HealthCheckType[];\n  status: HealthStatus;\n  metrics: Record<string, string | number | boolean>;\n  details?: Record<string, unknown>;\n}\n\nexport interface HealthThresholds {\n  degraded: number;\n  unhealthy: number;\n}\n\nexport interface HealthSecurityOptions {\n  token?: string;\n  ipWhitelist?: string[];\n}\n\nexport abstract class HealthCheck<TName extends string = string> {\n  constructor(\n    public readonly name: TName,\n    public readonly types: HealthCheckType[]\n  ) {}\n\n  /** Run this health check and return the result */\n  abstract run(): Promise<HealthCheckResult<TName>>;\n}\n", "import ping from \"ping\";\nimport { HealthCheck } from \"../core/types\";\nimport type { HealthStatus } from \"../core/types\";\n\nexport class NetworkHealthCheck extends HealthCheck<\"network\"> {\n  constructor(\n    private readonly host: string,\n    private readonly thresholds = { degraded: 200, unhealthy: 500 } // in ms\n  ) {\n    super(\"network\", [\"readiness\"]);\n  }\n\n  async run() {\n    const res = await ping.promise.probe(this.host);\n    const time = res.time ?? Infinity;\n\n    let status: HealthStatus = \"ok\";\n    if (time > this.thresholds.unhealthy) status = \"unhealthy\";\n    else if (time > this.thresholds.degraded) status = \"degraded\";\n\n    return {\n      name: this.name,\n      type: this.types,\n      status,\n      metrics: { host: this.host, time: `${time} ms` },\n    };\n  }\n}\n", "import { cpu, currentLoad } from \"systeminformation\";\n\nimport { HealthCheck } from \"../core/types\";\n\nimport type { HealthStatus } from \"../core/types\";\n\nexport class ProcessorHealthCheck extends HealthCheck<\"processor\"> {\n  constructor (private readonly thresholds = { degraded: 0.85, unhealthy: 0.95, }) {\n    super(\n      \"processor\", [\"liveness\"]\n    );\n  }\n\n  async run () {\n    const { manufacturer, brand, model, cores, } = await cpu();\n    const { currentLoad: load, } = await currentLoad();\n\n    const ratio = load / 100;\n    let status: HealthStatus = \"ok\";\n    if (ratio > this.thresholds.unhealthy) status = \"unhealthy\";\n    else if (ratio > this.thresholds.degraded) status = \"degraded\";\n\n    return {\n      name: this.name,\n      type: this.types,\n      status,\n      metrics: {\n        cpu: `${manufacturer} ${brand} ${model}`,\n        cores,\n        load: `${load.toFixed(2)}%`,\n      },\n    };\n  }\n}\n", "import type { HealthStatus } from \"./types\";\n\nexport function aggregateStatus (statuses: HealthStatus[]): HealthStatus {\n  if (statuses.includes(\"unhealthy\")) return \"unhealthy\";\n  if (statuses.includes(\"degraded\")) return \"degraded\";\n  return \"ok\";\n}\n\nexport function formatDuration (seconds: number): string {\n  const h = Math.floor(seconds / 3600);\n  const m = Math.floor((seconds % 3600) / 60);\n  return `${h}h ${m}m`;\n}\n", "import { formatDuration } from \"../core/utils\";\nimport { HealthCheck, HealthStatus } from \"../core/types\";\n\nexport class UptimeHealthCheck extends HealthCheck<\"uptime\"> {\n  constructor() {\n    super(\"uptime\", [\"liveness\"]);\n  }\n\n  async run() {\n    const uptime = process.uptime();\n\n    return {\n      name: this.name,\n      type: this.types,\n      status: \"ok\" as HealthStatus,\n      metrics: { uptime: formatDuration(uptime) },\n    };\n  }\n}\n", "import { aggregateStatus } from \"./utils\";\nimport type {\n  HealthCheck,\n  HealthCheckResult,\n  HealthCheckType,\n  HealthSecurityOptions,\n} from \"./types\";\n\ninterface HealthManagerOptions {\n  checks?: HealthCheck[];\n  globalThresholds?: Record<string, unknown>;\n  security?: HealthSecurityOptions;\n}\n\nexport class HealthManager {\n  private readonly checks = new Map<string, HealthCheck>();\n  private readonly shutdownSignals = new Set<string>();\n  private shuttingDown = false;\n  private readonly security?: HealthSecurityOptions;\n\n  constructor(private readonly options?: HealthManagerOptions) {\n    this.security = options?.security;\n    options?.checks?.forEach((c) => this.addCheck(c));\n  }\n\n  addCheck(check: HealthCheck): this {\n    this.checks.set(check.name, check);\n    return this;\n  }\n\n  /** Gracefully mark system as shutting down */\n  setShutdownSignal(signals: NodeJS.Signals[] = [\"SIGTERM\", \"SIGINT\"]): this {\n    for (const s of signals) {\n      process.on(s, () => {\n        this.shuttingDown = true;\n      });\n      this.shutdownSignals.add(s);\n    }\n    return this;\n  }\n\n  isShuttingDown(): boolean {\n    return this.shuttingDown;\n  }\n\n  async run(type: HealthCheckType): Promise<HealthCheckResult<\"summary\">> {\n    if (this.shuttingDown) {\n      return {\n        name: \"summary\",\n        type: [type],\n        status: \"unhealthy\",\n        metrics: { shuttingDown: true },\n      };\n    }\n\n    const relevantChecks = Array.from(this.checks.values()).filter((c) =>\n      c.types.includes(type)\n    );\n\n    const results = await Promise.all(relevantChecks.map((c) => c.run()));\n    const overall = aggregateStatus(results.map((r) => r.status));\n\n    return {\n      name: \"summary\",\n      type: [type],\n      status: overall,\n      metrics: {\n        total: results.length,\n        ok: results.filter((r) => r.status === \"ok\").length,\n        degraded: results.filter((r) => r.status === \"degraded\").length,\n        unhealthy: results.filter((r) => r.status === \"unhealthy\").length,\n      },\n      details: Object.fromEntries(results.map((r) => [r.name, r])),\n    };\n  }\n\n  /** Optional security check helper */\n  authorize(token?: string, ip?: string): boolean {\n    if (!this.security) return true;\n    if (this.security.token && this.security.token !== token) return false;\n    if (\n      this.security.ipWhitelist &&\n      !this.security.ipWhitelist.includes(ip ?? \"\")\n    )\n      return false;\n    return true;\n  }\n}\n"],
  "mappings": ";0jBAAA,IAAAA,EAAA,GAAAC,EAAAD,EAAA,iBAAAE,EAAA,kBAAAC,EAAA,sBAAAC,EAAA,uBAAAC,EAAA,yBAAAC,EAAA,sBAAAC,IAAA,eAAAC,EAAAR,GCAA,IAAAS,EAAyB,oBACzBC,EAAoB,6BCqBb,IAAeC,EAAf,KAA0D,CAC/D,YACkBC,EACAC,EAChB,CAFgB,UAAAD,EACA,WAAAC,CACf,CAIL,EDzBO,IAAMC,EAAN,cAAgCC,CAAsB,CAC3D,YACmBC,EAAa,CAAE,SAAU,IAAM,UAAW,GAAK,EAChE,CACA,MAAM,SAAU,CAAC,WAAY,WAAW,CAAC,EAFxB,gBAAAA,CAGnB,CAEA,MAAM,KAAM,CACV,GAAM,CAAE,KAAAC,EAAM,MAAAC,EAAO,KAAAC,CAAK,EAAI,QAAM,OAAI,EAClCC,EAAQH,EAAOC,EAEjBG,EAAuB,KAC3B,OAAID,EAAQ,KAAK,WAAW,UAAWC,EAAS,YACvCD,EAAQ,KAAK,WAAW,WAAUC,EAAS,YAE7C,CACL,KAAM,KAAK,KACX,KAAM,KAAK,MACX,OAAAA,EACA,QAAS,CACP,SAAO,YAASH,CAAK,EACrB,QAAM,YAASC,CAAI,EACnB,QAAM,YAASF,CAAI,EACnB,YAAa,IAAIG,EAAQ,KAAK,QAAQ,CAAC,CAAC,GAC1C,CACF,CACF,CACF,EEhCA,IAAAE,EAAiB,qBAIV,IAAMC,EAAN,c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Q,IAAID,EAAe,IAAKL,GAAMA,EAAE,IAAI,CAAC,CAAC,EAC9DO,EAAUC,EAAgBF,EAAQ,IAAKG,GAAMA,EAAE,MAAM,CAAC,EAE5D,MAAO,CACL,KAAM,UACN,KAAM,CAACL,CAAI,EACX,OAAQG,EACR,QAAS,CACP,MAAOD,EAAQ,OACf,GAAIA,EAAQ,OAAQG,GAAMA,EAAE,SAAW,IAAI,EAAE,OAC7C,SAAUH,EAAQ,OAAQG,GAAMA,EAAE,SAAW,UAAU,EAAE,OACzD,UAAWH,EAAQ,OAAQG,GAAMA,EAAE,SAAW,WAAW,EAAE,MAC7D,EACA,QAAS,OAAO,YAAYH,EAAQ,IAAKG,GAAM,CAACA,EAAE,KAAMA,CAAC,CAAC,CAAC,CAC7D,CACF,CAGA,UAAUC,EAAgBC,EAAsB,CAC9C,OAAK,KAAK,SACN,OAAK,SAAS,OAAS,KAAK,SAAS,QAAUD,GAEjD,KAAK,SAAS,aACd,CAAC,KAAK,SAAS,YAAY,SAASC,GAAM,EAAE,GAJnB,EAQ7B,CACF",
  "names": ["index_exports", "__export", "HealthCheck", "HealthManager", "MemoryHealthCheck", "NetworkHealthCheck", "ProcessorHealthCheck", "UptimeHealthCheck", "__toCommonJS", "import_filesize", "import_systeminformation", "HealthCheck", "name", "types", "MemoryHealthCheck", "HealthCheck", "thresholds", "free", "total", "used", "ratio", "status", "import_ping", "NetworkHealthCheck", "HealthCheck", "host", "thresholds", "time", "ping", "status", "import_systeminformation", "ProcessorHealthCheck", "HealthCheck", "thresholds", "manufacturer", "brand", "model", "cores", "load", "ratio", "status", "aggregateStatus", "statuses", "formatDuration", "seconds", "h", "m", "UptimeHealthCheck", "HealthCheck", "uptime", "formatDuration", "HealthManager", "options", "_a", "c", "check", "signals", "s", "type", "relevantChecks", "results", "overall", "aggregateStatus", "r", "token", "ip"]
}
