@firebreak/vitals 2.0.1 → 2.2.0

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/README.md CHANGED
@@ -321,7 +321,37 @@ createHealthcheckHandler({
321
321
  });
322
322
  ```
323
323
 
324
- Metadata values can be `string`, `number`, or `boolean`. Keys `status`, `timestamp`, and `checks` are reserved passing them throws at handler creation time.
324
+ Metadata values can be `string`, `number`, or `boolean`. Keys `status`, `timestamp`, `checks`, and `cachedAt` are reserved -- passing them throws at handler creation time.
325
+
326
+ #### `shallowMetadata`
327
+
328
+ By default, shallow responses include all `metadata` fields. Use `shallowMetadata` to override what appears in shallow responses while keeping `metadata` for deep responses:
329
+
330
+ ```typescript
331
+ createHealthcheckHandler({
332
+ registry,
333
+ metadata: {
334
+ build: 'stg-45d76e5',
335
+ buildTimestamp: '2025-02-25T19:41:56Z',
336
+ region: 'us-east-1',
337
+ },
338
+ // Shallow responses only include status + timestamp (no build info)
339
+ shallowMetadata: {},
340
+ });
341
+ ```
342
+
343
+ You can also include a subset of fields:
344
+
345
+ ```typescript
346
+ createHealthcheckHandler({
347
+ registry,
348
+ metadata: { build: 'stg-45d76e5', region: 'us-east-1', version: '1.0.0' },
349
+ // Shallow responses include only version
350
+ shallowMetadata: { version: '1.0.0' },
351
+ });
352
+ ```
353
+
354
+ When `shallowMetadata` is omitted, shallow responses fall back to using `metadata` (existing behavior).
325
355
 
326
356
  ### Utilities
327
357
 
@@ -5,6 +5,7 @@ interface HealthcheckHandlerOptions {
5
5
  registry: HealthcheckRegistry;
6
6
  resolveDepth?: ResolveDepthFn;
7
7
  metadata?: Record<string, string | number | boolean>;
8
+ shallowMetadata?: Record<string, string | number | boolean>;
8
9
  }
9
10
  interface ShallowResponseJson {
10
11
  status: 'ok';
@@ -5,6 +5,7 @@ interface HealthcheckHandlerOptions {
5
5
  registry: HealthcheckRegistry;
6
6
  resolveDepth?: ResolveDepthFn;
7
7
  metadata?: Record<string, string | number | boolean>;
8
+ shallowMetadata?: Record<string, string | number | boolean>;
8
9
  }
9
10
  interface ShallowResponseJson {
10
11
  status: 'ok';
package/dist/index.cjs CHANGED
@@ -220,10 +220,12 @@ function extractToken(options) {
220
220
  // src/handler.ts
221
221
  var RESERVED_METADATA_KEYS = ["status", "timestamp", "checks", "cachedAt"];
222
222
  function createHealthcheckHandler(options) {
223
- const { registry, resolveDepth, metadata = {} } = options;
224
- for (const key of Object.keys(metadata)) {
225
- if (RESERVED_METADATA_KEYS.includes(key)) {
226
- throw new Error(`Metadata key '${key}' is reserved. Use a different key name.`);
223
+ const { registry, resolveDepth, metadata = {}, shallowMetadata } = options;
224
+ for (const bag of [metadata, shallowMetadata ?? {}]) {
225
+ for (const key of Object.keys(bag)) {
226
+ if (RESERVED_METADATA_KEYS.includes(key)) {
227
+ throw new Error(`Metadata key '${key}' is reserved. Use a different key name.`);
228
+ }
227
229
  }
228
230
  }
229
231
  return async (req) => {
@@ -247,7 +249,7 @@ function createHealthcheckHandler(options) {
247
249
  const body = {
248
250
  status: "ok",
249
251
  timestamp: (/* @__PURE__ */ new Date()).toISOString(),
250
- ...metadata
252
+ ...shallowMetadata ?? metadata
251
253
  };
252
254
  return { status: 200, body };
253
255
  };
package/dist/index.d.cts CHANGED
@@ -1,7 +1,7 @@
1
1
  import { H as HealthcheckResponseJson } from './core-Bee03bJm.cjs';
2
2
  export { A as AsyncCheckFn, C as CheckInput, a as CheckResult, b as HealthcheckRegistry, c as HealthcheckResponse, S as Status, d as StatusLabel, e as StatusValue, f as SyncCheckFn, h as httpStatusCode, s as statusFromString, g as statusToLabel, i as syncCheck, t as toJson } from './core-Bee03bJm.cjs';
3
- import { S as ShallowResponseJson } from './handler-TZOgZvY7.cjs';
4
- export { H as HealthcheckHandlerOptions, a as HealthcheckHandlerResult, R as ResolveDepthFn, c as createHealthcheckHandler } from './handler-TZOgZvY7.cjs';
3
+ import { S as ShallowResponseJson } from './handler-C3eTDuSQ.cjs';
4
+ export { H as HealthcheckHandlerOptions, a as HealthcheckHandlerResult, R as ResolveDepthFn, c as createHealthcheckHandler } from './handler-C3eTDuSQ.cjs';
5
5
 
6
6
  declare function verifyToken(provided: string, expected: string): boolean;
7
7
  declare function extractToken(options: {
package/dist/index.d.ts CHANGED
@@ -1,7 +1,7 @@
1
1
  import { H as HealthcheckResponseJson } from './core-Bee03bJm.js';
2
2
  export { A as AsyncCheckFn, C as CheckInput, a as CheckResult, b as HealthcheckRegistry, c as HealthcheckResponse, S as Status, d as StatusLabel, e as StatusValue, f as SyncCheckFn, h as httpStatusCode, s as statusFromString, g as statusToLabel, i as syncCheck, t as toJson } from './core-Bee03bJm.js';
3
- import { S as ShallowResponseJson } from './handler-BvjN4Ot9.js';
4
- export { H as HealthcheckHandlerOptions, a as HealthcheckHandlerResult, R as ResolveDepthFn, c as createHealthcheckHandler } from './handler-BvjN4Ot9.js';
3
+ import { S as ShallowResponseJson } from './handler-DaFJivGK.js';
4
+ export { H as HealthcheckHandlerOptions, a as HealthcheckHandlerResult, R as ResolveDepthFn, c as createHealthcheckHandler } from './handler-DaFJivGK.js';
5
5
 
6
6
  declare function verifyToken(provided: string, expected: string): boolean;
7
7
  declare function extractToken(options: {
package/dist/index.mjs CHANGED
@@ -184,10 +184,12 @@ function extractToken(options) {
184
184
  // src/handler.ts
185
185
  var RESERVED_METADATA_KEYS = ["status", "timestamp", "checks", "cachedAt"];
186
186
  function createHealthcheckHandler(options) {
187
- const { registry, resolveDepth, metadata = {} } = options;
188
- for (const key of Object.keys(metadata)) {
189
- if (RESERVED_METADATA_KEYS.includes(key)) {
190
- throw new Error(`Metadata key '${key}' is reserved. Use a different key name.`);
187
+ const { registry, resolveDepth, metadata = {}, shallowMetadata } = options;
188
+ for (const bag of [metadata, shallowMetadata ?? {}]) {
189
+ for (const key of Object.keys(bag)) {
190
+ if (RESERVED_METADATA_KEYS.includes(key)) {
191
+ throw new Error(`Metadata key '${key}' is reserved. Use a different key name.`);
192
+ }
191
193
  }
192
194
  }
193
195
  return async (req) => {
@@ -211,7 +213,7 @@ function createHealthcheckHandler(options) {
211
213
  const body = {
212
214
  status: "ok",
213
215
  timestamp: (/* @__PURE__ */ new Date()).toISOString(),
214
- ...metadata
216
+ ...shallowMetadata ?? metadata
215
217
  };
216
218
  return { status: 200, body };
217
219
  };
@@ -61,10 +61,12 @@ function httpStatusCode(status) {
61
61
  // src/handler.ts
62
62
  var RESERVED_METADATA_KEYS = ["status", "timestamp", "checks", "cachedAt"];
63
63
  function createHealthcheckHandler(options) {
64
- const { registry, resolveDepth, metadata = {} } = options;
65
- for (const key of Object.keys(metadata)) {
66
- if (RESERVED_METADATA_KEYS.includes(key)) {
67
- throw new Error(`Metadata key '${key}' is reserved. Use a different key name.`);
64
+ const { registry, resolveDepth, metadata = {}, shallowMetadata } = options;
65
+ for (const bag of [metadata, shallowMetadata ?? {}]) {
66
+ for (const key of Object.keys(bag)) {
67
+ if (RESERVED_METADATA_KEYS.includes(key)) {
68
+ throw new Error(`Metadata key '${key}' is reserved. Use a different key name.`);
69
+ }
68
70
  }
69
71
  }
70
72
  return async (req) => {
@@ -88,7 +90,7 @@ function createHealthcheckHandler(options) {
88
90
  const body = {
89
91
  status: "ok",
90
92
  timestamp: (/* @__PURE__ */ new Date()).toISOString(),
91
- ...metadata
93
+ ...shallowMetadata ?? metadata
92
94
  };
93
95
  return { status: 200, body };
94
96
  };
@@ -1,5 +1,5 @@
1
1
  import { RequestHandler } from 'express';
2
- import { H as HealthcheckHandlerOptions } from '../handler-TZOgZvY7.cjs';
2
+ import { H as HealthcheckHandlerOptions } from '../handler-C3eTDuSQ.cjs';
3
3
  import '../core-Bee03bJm.cjs';
4
4
 
5
5
  type HealthcheckMiddlewareOptions = HealthcheckHandlerOptions;
@@ -1,5 +1,5 @@
1
1
  import { RequestHandler } from 'express';
2
- import { H as HealthcheckHandlerOptions } from '../handler-BvjN4Ot9.js';
2
+ import { H as HealthcheckHandlerOptions } from '../handler-DaFJivGK.js';
3
3
  import '../core-Bee03bJm.js';
4
4
 
5
5
  type HealthcheckMiddlewareOptions = HealthcheckHandlerOptions;
@@ -35,10 +35,12 @@ function httpStatusCode(status) {
35
35
  // src/handler.ts
36
36
  var RESERVED_METADATA_KEYS = ["status", "timestamp", "checks", "cachedAt"];
37
37
  function createHealthcheckHandler(options) {
38
- const { registry, resolveDepth, metadata = {} } = options;
39
- for (const key of Object.keys(metadata)) {
40
- if (RESERVED_METADATA_KEYS.includes(key)) {
41
- throw new Error(`Metadata key '${key}' is reserved. Use a different key name.`);
38
+ const { registry, resolveDepth, metadata = {}, shallowMetadata } = options;
39
+ for (const bag of [metadata, shallowMetadata ?? {}]) {
40
+ for (const key of Object.keys(bag)) {
41
+ if (RESERVED_METADATA_KEYS.includes(key)) {
42
+ throw new Error(`Metadata key '${key}' is reserved. Use a different key name.`);
43
+ }
42
44
  }
43
45
  }
44
46
  return async (req) => {
@@ -62,7 +64,7 @@ function createHealthcheckHandler(options) {
62
64
  const body = {
63
65
  status: "ok",
64
66
  timestamp: (/* @__PURE__ */ new Date()).toISOString(),
65
- ...metadata
67
+ ...shallowMetadata ?? metadata
66
68
  };
67
69
  return { status: 200, body };
68
70
  };
@@ -61,10 +61,12 @@ function httpStatusCode(status) {
61
61
  // src/handler.ts
62
62
  var RESERVED_METADATA_KEYS = ["status", "timestamp", "checks", "cachedAt"];
63
63
  function createHealthcheckHandler(options) {
64
- const { registry, resolveDepth, metadata = {} } = options;
65
- for (const key of Object.keys(metadata)) {
66
- if (RESERVED_METADATA_KEYS.includes(key)) {
67
- throw new Error(`Metadata key '${key}' is reserved. Use a different key name.`);
64
+ const { registry, resolveDepth, metadata = {}, shallowMetadata } = options;
65
+ for (const bag of [metadata, shallowMetadata ?? {}]) {
66
+ for (const key of Object.keys(bag)) {
67
+ if (RESERVED_METADATA_KEYS.includes(key)) {
68
+ throw new Error(`Metadata key '${key}' is reserved. Use a different key name.`);
69
+ }
68
70
  }
69
71
  }
70
72
  return async (req) => {
@@ -88,7 +90,7 @@ function createHealthcheckHandler(options) {
88
90
  const body = {
89
91
  status: "ok",
90
92
  timestamp: (/* @__PURE__ */ new Date()).toISOString(),
91
- ...metadata
93
+ ...shallowMetadata ?? metadata
92
94
  };
93
95
  return { status: 200, body };
94
96
  };
@@ -1,4 +1,4 @@
1
- import { H as HealthcheckHandlerOptions } from '../handler-TZOgZvY7.cjs';
1
+ import { H as HealthcheckHandlerOptions } from '../handler-C3eTDuSQ.cjs';
2
2
  import '../core-Bee03bJm.cjs';
3
3
 
4
4
  type NextHealthcheckOptions = HealthcheckHandlerOptions;
@@ -1,4 +1,4 @@
1
- import { H as HealthcheckHandlerOptions } from '../handler-BvjN4Ot9.js';
1
+ import { H as HealthcheckHandlerOptions } from '../handler-DaFJivGK.js';
2
2
  import '../core-Bee03bJm.js';
3
3
 
4
4
  type NextHealthcheckOptions = HealthcheckHandlerOptions;
@@ -35,10 +35,12 @@ function httpStatusCode(status) {
35
35
  // src/handler.ts
36
36
  var RESERVED_METADATA_KEYS = ["status", "timestamp", "checks", "cachedAt"];
37
37
  function createHealthcheckHandler(options) {
38
- const { registry, resolveDepth, metadata = {} } = options;
39
- for (const key of Object.keys(metadata)) {
40
- if (RESERVED_METADATA_KEYS.includes(key)) {
41
- throw new Error(`Metadata key '${key}' is reserved. Use a different key name.`);
38
+ const { registry, resolveDepth, metadata = {}, shallowMetadata } = options;
39
+ for (const bag of [metadata, shallowMetadata ?? {}]) {
40
+ for (const key of Object.keys(bag)) {
41
+ if (RESERVED_METADATA_KEYS.includes(key)) {
42
+ throw new Error(`Metadata key '${key}' is reserved. Use a different key name.`);
43
+ }
42
44
  }
43
45
  }
44
46
  return async (req) => {
@@ -62,7 +64,7 @@ function createHealthcheckHandler(options) {
62
64
  const body = {
63
65
  status: "ok",
64
66
  timestamp: (/* @__PURE__ */ new Date()).toISOString(),
65
- ...metadata
67
+ ...shallowMetadata ?? metadata
66
68
  };
67
69
  return { status: 200, body };
68
70
  };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@firebreak/vitals",
3
- "version": "2.0.1",
3
+ "version": "2.2.0",
4
4
  "description": "Deep healthcheck endpoints following the HEALTHCHECK_SPEC format",
5
5
  "type": "module",
6
6
  "exports": {
@@ -75,6 +75,28 @@
75
75
  }
76
76
  }
77
77
  },
78
+ "typesVersions": {
79
+ "*": {
80
+ "express": [
81
+ "./dist/integrations/express.d.ts"
82
+ ],
83
+ "next": [
84
+ "./dist/integrations/next.d.ts"
85
+ ],
86
+ "checks/postgres": [
87
+ "./dist/checks/postgres.d.ts"
88
+ ],
89
+ "checks/http": [
90
+ "./dist/checks/http.d.ts"
91
+ ],
92
+ "checks/databricks": [
93
+ "./dist/checks/databricks.d.ts"
94
+ ],
95
+ "checks/redis": [
96
+ "./dist/checks/redis.d.ts"
97
+ ]
98
+ }
99
+ },
78
100
  "main": "./dist/index.cjs",
79
101
  "module": "./dist/index.mjs",
80
102
  "types": "./dist/index.d.ts",