@dunx/http 3.9.0 → 3.9.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.
@@ -11,6 +11,17 @@ export interface ProbeResult {
11
11
  readonly state: ProbeState;
12
12
  /** One line for the operator: a latency, a version, a failure message. */
13
13
  readonly detail?: string;
14
+ /**
15
+ * The same facts as values, for what reads the report but not prose - an alert
16
+ * rule, a panel, a scrape. `500f` meaning five hundred failed jobs is
17
+ * otherwise actionable only by a human. Serialised as it stands, so keep it
18
+ * JSON.
19
+ *
20
+ * ```ts
21
+ * return { state: 'up', detail: `${failed} failed`, data: { failed } };
22
+ * ```
23
+ */
24
+ readonly data?: Readonly<Record<string, unknown>>;
14
25
  }
15
26
  /**
16
27
  * One thing worth checking.
@@ -7,6 +7,8 @@ export interface HealthCheckReport {
7
7
  /** How long the check took, rounded to a millisecond. */
8
8
  readonly ms: number;
9
9
  readonly detail?: string;
10
+ /** The check's own structured facts, carried through as it gave them. */
11
+ readonly data?: Readonly<Record<string, unknown>>;
10
12
  }
11
13
  /**
12
14
  * The wire format, declared here and imported by anything that renders it.
package/dist/index.js CHANGED
@@ -3062,6 +3062,11 @@ var HEALTH_REPORT_SCHEMA = Object.freeze({
3062
3062
  detail: {
3063
3063
  type: "string",
3064
3064
  description: "A latency, a version, or a failure message."
3065
+ },
3066
+ data: {
3067
+ type: "object",
3068
+ description: "The same facts as values, for a scrape rather than a reader.",
3069
+ additionalProperties: true
3065
3070
  }
3066
3071
  },
3067
3072
  required: ["name", "state", "critical", "ms"]
@@ -3135,7 +3140,8 @@ class HealthRegistry {
3135
3140
  state: result.state,
3136
3141
  critical: indicator.critical,
3137
3142
  ms: Math.round(performance.now() - started),
3138
- ...result.detail === undefined ? {} : { detail: result.detail }
3143
+ ...result.detail === undefined ? {} : { detail: result.detail },
3144
+ ...result.data === undefined ? {} : { data: result.data }
3139
3145
  };
3140
3146
  }));
3141
3147
  return {
@@ -3234,7 +3240,8 @@ class RoundTripIndicator extends HealthIndicator {
3234
3240
  async check() {
3235
3241
  const started = performance.now();
3236
3242
  await this.probe.ping();
3237
- return { state: "up", detail: `${ms(started)} ms` };
3243
+ const roundTripMs = ms(started);
3244
+ return { state: "up", detail: `${roundTripMs} ms`, data: { roundTripMs } };
3238
3245
  }
3239
3246
  }
3240
3247
  Object.defineProperty(RoundTripIndicator, Symbol.for("dunx.deps"), { value: () => [{ unresolved: "private readonly probe: QueryProbe", typeOnly: "QueryProbe" }] });
@@ -3279,7 +3286,8 @@ class StorageIndicator extends HealthIndicator {
3279
3286
  async check() {
3280
3287
  const started = performance.now();
3281
3288
  await this.storage.exists(this.options.key);
3282
- return { state: "up", detail: `${ms(started)} ms` };
3289
+ const roundTripMs = ms(started);
3290
+ return { state: "up", detail: `${roundTripMs} ms`, data: { roundTripMs } };
3283
3291
  }
3284
3292
  }
3285
3293
  Object.defineProperty(StorageIndicator, Symbol.for("dunx.deps"), { value: () => [{ unresolved: "private readonly storage: StorageProbe", typeOnly: "StorageProbe" }, StorageProbeOptions] });
@@ -3305,7 +3313,8 @@ class MemoryIndicator extends HealthIndicator {
3305
3313
  check() {
3306
3314
  const { rss } = process.memoryUsage();
3307
3315
  const detail = `${mib(rss)} of ${mib(this.options.maxRssBytes)}`;
3308
- return rss > this.options.maxRssBytes ? { state: "down", detail } : { state: "up", detail };
3316
+ const data = { rssBytes: rss, maxRssBytes: this.options.maxRssBytes };
3317
+ return rss > this.options.maxRssBytes ? { state: "down", detail, data } : { state: "up", detail, data };
3309
3318
  }
3310
3319
  }
3311
3320
  Object.defineProperty(MemoryIndicator, Symbol.for("dunx.deps"), { value: () => [MemoryOptions] });
@@ -3336,7 +3345,8 @@ class DiskIndicator extends HealthIndicator {
3336
3345
  return { state: "unknown", detail: "no size reported" };
3337
3346
  const used = (total - free) / total;
3338
3347
  const detail = `${Math.round(used * 100)}% of ${mib(total)} used`;
3339
- return used > this.options.maxUsedFraction ? { state: "down", detail } : { state: "up", detail };
3348
+ const data = { totalBytes: total, freeBytes: free, usedFraction: used };
3349
+ return used > this.options.maxUsedFraction ? { state: "down", detail, data } : { state: "up", detail, data };
3340
3350
  }
3341
3351
  }
3342
3352
  Object.defineProperty(DiskIndicator, Symbol.for("dunx.deps"), { value: () => [DiskOptions] });
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@dunx/http",
3
- "version": "3.9.0",
3
+ "version": "3.9.1",
4
4
  "description": "Bun.serve adapter for the dunx framework: controllers, middleware and WebSocket gateways",
5
5
  "keywords": [
6
6
  "bun",
@@ -76,7 +76,7 @@
76
76
  "peerDependencies": {
77
77
  "@bufbuild/protobuf": "^2.15.0",
78
78
  "@connectrpc/connect": "^2.2.0",
79
- "@dunx/core": "^3.9.0",
79
+ "@dunx/core": "^3.9.1",
80
80
  "@types/bun": ">=1.4.1"
81
81
  },
82
82
  "peerDependenciesMeta": {