@lahin31/debugcontext-core 0.1.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.
@@ -0,0 +1,332 @@
1
+ /**
2
+ * @module types
3
+ * Core type definitions for DebugContext incidents.
4
+ */
5
+ /** HTTP request context captured at the time of the error. */
6
+ interface RequestContext {
7
+ /** HTTP method (GET, POST, …) */
8
+ method: string;
9
+ /** Full request URL including query string */
10
+ url: string;
11
+ /** Express-style named route params, e.g. { id: "42" } */
12
+ params: Record<string, string>;
13
+ /** Parsed query-string parameters */
14
+ query: Record<string, string | string[]>;
15
+ /** Request body — sensitive fields are redacted */
16
+ body: unknown;
17
+ /** Selected headers — auth / cookie values are redacted */
18
+ headers: Record<string, string>;
19
+ /** Client IP address */
20
+ ip: string;
21
+ /** User-Agent string */
22
+ userAgent: string;
23
+ }
24
+ /** Node.js runtime context at the time of the error. */
25
+ interface RuntimeContext {
26
+ /** ISO-8601 timestamp */
27
+ timestamp: string;
28
+ /** NODE_ENV value, defaults to "development" */
29
+ environment: string;
30
+ /** process.version */
31
+ nodeVersion: string;
32
+ /** process.pid */
33
+ pid: number;
34
+ /** os.hostname() */
35
+ hostname: string;
36
+ /** process.uptime() in seconds */
37
+ uptimeSeconds: number;
38
+ /** process.cwd() */
39
+ workingDirectory: string;
40
+ }
41
+ /** Operating-system / process memory context. */
42
+ interface SystemContext {
43
+ /** process.memoryUsage() */
44
+ memory: {
45
+ rss: number;
46
+ heapTotal: number;
47
+ heapUsed: number;
48
+ external: number;
49
+ arrayBuffers: number;
50
+ };
51
+ /** Heap usage as a percentage 0-100 */
52
+ heapUsagePercent: number;
53
+ /** os.loadavg() — [1m, 5m, 15m] */
54
+ cpuLoadAvg: [number, number, number];
55
+ /** os.platform() */
56
+ platform: string;
57
+ /** os.arch() */
58
+ arch: string;
59
+ /** Total system memory in bytes */
60
+ totalMemory: number;
61
+ /** Free system memory in bytes */
62
+ freeMemory: number;
63
+ }
64
+ /** Git / package metadata resolved at startup. */
65
+ interface GitContext {
66
+ /** Short (8-char) commit hash, or "unknown" */
67
+ commitHash: string;
68
+ /** Current branch name, or "unknown" */
69
+ branch: string;
70
+ /** version field from the nearest package.json */
71
+ packageVersion: string;
72
+ }
73
+ /** Serialisable error context. */
74
+ interface ErrorContext {
75
+ /** Error constructor name */
76
+ name: string;
77
+ /** Error message */
78
+ message: string;
79
+ /** Full stack trace */
80
+ stack: string | undefined;
81
+ /** Serialised error.cause if present */
82
+ cause: unknown;
83
+ }
84
+ /**
85
+ * A fully structured debugging snapshot produced whenever an unhandled error
86
+ * or a caught framework error occurs.
87
+ */
88
+ interface Incident {
89
+ /** Unique ID for this incident (UUID v4) */
90
+ incidentId: string;
91
+ /** ISO-8601 timestamp — duplicated here for quick top-level access */
92
+ timestamp: string;
93
+ /** HTTP request that was in-flight when the error occurred (may be null) */
94
+ request: RequestContext | null;
95
+ /** Node.js runtime snapshot */
96
+ runtime: RuntimeContext;
97
+ /** System resource snapshot */
98
+ system: SystemContext;
99
+ /** Git / package metadata */
100
+ git: GitContext;
101
+ /** Serialised error */
102
+ error: ErrorContext;
103
+ }
104
+ /**
105
+ * Options accepted by `DebugContext.init()`.
106
+ * Everything is optional — the SDK works with zero configuration.
107
+ */
108
+ interface DebugContextOptions {
109
+ /**
110
+ * Additional header names whose values should be redacted.
111
+ * Merged with the built-in sensitive header list.
112
+ */
113
+ sensitiveHeaders?: string[];
114
+ /**
115
+ * Additional body field names whose values should be redacted.
116
+ * Merged with the built-in sensitive field list.
117
+ */
118
+ sensitiveFields?: string[];
119
+ /**
120
+ * Called after each incident is captured.
121
+ * Use this hook to ship incidents to your own storage / alerting.
122
+ *
123
+ * @example
124
+ * DebugContext.init({
125
+ * onIncident: (incident) => myStorage.save(incident),
126
+ * });
127
+ */
128
+ onIncident?: (incident: Incident) => void | Promise<void>;
129
+ /**
130
+ * When true, DebugContext attaches a global `uncaughtException` +
131
+ * `unhandledRejection` listener. Defaults to `true`.
132
+ */
133
+ captureGlobalErrors?: boolean;
134
+ }
135
+
136
+ interface ToFileOptions {
137
+ /**
138
+ * Path to the output file.
139
+ * @default "incidents.ndjson" (relative to process.cwd())
140
+ */
141
+ path?: string;
142
+ /**
143
+ * When `true`, creates parent directories if they don't exist.
144
+ * @default true
145
+ */
146
+ mkdirp?: boolean;
147
+ }
148
+ /**
149
+ * Appends an incident as a single JSON line to an NDJSON file.
150
+ *
151
+ * - Safe to call from multiple processes (append is atomic on most OSes).
152
+ * - Synchronous by design so it can be called inside `onIncident` without
153
+ * worrying about buffering or unhandled promise rejections.
154
+ *
155
+ * @param incident - The incident to write.
156
+ * @param options - Output options.
157
+ *
158
+ * @example
159
+ * ```ts
160
+ * // Write to the default path (incidents.ndjson)
161
+ * DebugContext.toFile(incident);
162
+ *
163
+ * // Write to a custom path
164
+ * DebugContext.toFile(incident, { path: 'logs/incidents.ndjson' });
165
+ * ```
166
+ */
167
+ declare function toFile$1(incident: Incident, options?: ToFileOptions): void;
168
+
169
+ /**
170
+ * Initialises DebugContext with optional configuration.
171
+ *
172
+ * Call once at application startup — before your Express app starts
173
+ * accepting requests.
174
+ *
175
+ * @example
176
+ * ```ts
177
+ * import DebugContext from '@debugcontext/core';
178
+ *
179
+ * DebugContext.init({ onIncident: (i) => console.log(i) });
180
+ * ```
181
+ */
182
+ declare function init(userOptions?: DebugContextOptions): void;
183
+ /**
184
+ * Captures an error (and an optional request context provided by a framework
185
+ * adapter) into a structured Incident.
186
+ *
187
+ * @param error - The thrown value.
188
+ * @param request - Optional request context from a framework adapter.
189
+ * @returns The captured Incident.
190
+ *
191
+ * @example
192
+ * ```ts
193
+ * try {
194
+ * riskyOperation();
195
+ * } catch (err) {
196
+ * const incident = DebugContext.capture(err);
197
+ * DebugContext.toConsole(incident);
198
+ * }
199
+ * ```
200
+ */
201
+ declare function capture(error: unknown, request?: RequestContext | null): Incident;
202
+ /**
203
+ * Returns the most recently captured Incident as a JSON string.
204
+ *
205
+ * @param incident - Incident to serialise. Defaults to the last captured one.
206
+ * @returns Pretty-printed JSON string, or `null` if no incident has been captured.
207
+ */
208
+ declare function toJSON(incident?: Incident): string | null;
209
+ /**
210
+ * Prints the incident to the console in a human-readable format.
211
+ *
212
+ * @param incident - Incident to print. Defaults to the last captured one.
213
+ */
214
+ declare function toConsole(incident?: Incident): void;
215
+ /**
216
+ * Appends the incident to a newline-delimited JSON (NDJSON) file.
217
+ * Creates the file and parent directories if they don't exist.
218
+ *
219
+ * @param incident - Incident to write. Defaults to the last captured one.
220
+ * @param options - `{ path?: string }` — defaults to `"incidents.ndjson"`.
221
+ *
222
+ * @example
223
+ * ```ts
224
+ * DebugContext.init({
225
+ * onIncident: (i) => DebugContext.toFile(i, { path: 'logs/incidents.ndjson' }),
226
+ * });
227
+ * ```
228
+ */
229
+ declare function toFile(incident?: Incident, options?: ToFileOptions): void;
230
+ /**
231
+ * Returns a framework-agnostic capture function pre-bound to the current
232
+ * options. Useful when building custom adapters.
233
+ *
234
+ * For Express, use `@debugcontext/express` instead.
235
+ *
236
+ * @example
237
+ * ```ts
238
+ * // In a custom adapter:
239
+ * const mw = DebugContext.middleware();
240
+ * app.use((err, req, res, next) => {
241
+ * const requestCtx = buildRequestCtx(req);
242
+ * mw(err, requestCtx);
243
+ * next(err);
244
+ * });
245
+ * ```
246
+ */
247
+ declare function middleware(): (error: unknown, request?: RequestContext | null) => Incident;
248
+ /**
249
+ * Returns the current SDK options (useful for adapters).
250
+ * @internal
251
+ */
252
+ declare function getOptions(): Required<DebugContextOptions>;
253
+ /**
254
+ * The DebugContext SDK.
255
+ *
256
+ * @example
257
+ * ```ts
258
+ * import DebugContext from '@debugcontext/core';
259
+ *
260
+ * DebugContext.init();
261
+ * ```
262
+ */
263
+ declare const DebugContext: {
264
+ readonly init: typeof init;
265
+ readonly capture: typeof capture;
266
+ readonly toJSON: typeof toJSON;
267
+ readonly toConsole: typeof toConsole;
268
+ readonly toFile: typeof toFile;
269
+ readonly middleware: typeof middleware;
270
+ /** @internal used by framework adapters */
271
+ readonly getOptions: typeof getOptions;
272
+ };
273
+
274
+ /**
275
+ * @module collectors/error
276
+ * Serialises a thrown value into a structured ErrorContext.
277
+ */
278
+
279
+ /**
280
+ * Converts any thrown value into a structured, serialisable ErrorContext.
281
+ *
282
+ * Handles:
283
+ * - Standard `Error` instances (including subclasses).
284
+ * - Errors with a `.cause` (ES2022 error chaining).
285
+ * - Non-Error throws (strings, objects, etc.).
286
+ */
287
+ declare function collectError(thrown: unknown): ErrorContext;
288
+
289
+ /**
290
+ * Returns the Git context. Resolution runs once and is then cached for the
291
+ * lifetime of the process.
292
+ */
293
+ declare function collectGit(): GitContext;
294
+
295
+ /**
296
+ * Captures a snapshot of the current Node.js runtime environment.
297
+ */
298
+ declare function collectRuntime(): RuntimeContext;
299
+
300
+ /**
301
+ * Captures a snapshot of current system resource usage.
302
+ */
303
+ declare function collectSystem(): SystemContext;
304
+
305
+ /**
306
+ * @module redact
307
+ * Utilities for scrubbing sensitive data from headers and request bodies
308
+ * before they are included in an Incident.
309
+ */
310
+ /** Header names that are always redacted (case-insensitive comparison). */
311
+ declare const DEFAULT_SENSITIVE_HEADERS: readonly string[];
312
+ /** Body / object field names that are always redacted (case-insensitive). */
313
+ declare const DEFAULT_SENSITIVE_FIELDS: readonly string[];
314
+ /**
315
+ * Returns a copy of `headers` where sensitive values are replaced with
316
+ * `"[REDACTED]"`.
317
+ *
318
+ * @param headers - Raw header map (values may be string or string[]).
319
+ * @param extraFields - Caller-supplied additional header names to redact.
320
+ */
321
+ declare function redactHeaders(headers: Record<string, string | string[] | undefined>, extraFields?: string[]): Record<string, string>;
322
+ /**
323
+ * Deeply walks `body` (plain objects / arrays) and replaces the *values* of
324
+ * sensitive keys with `"[REDACTED]"`. Non-plain-object values are returned
325
+ * as-is (e.g. strings, numbers, Buffers).
326
+ *
327
+ * @param body - The request body to sanitise.
328
+ * @param extraFields - Caller-supplied additional field names to redact.
329
+ */
330
+ declare function redactBody(body: unknown, extraFields?: string[]): unknown;
331
+
332
+ export { DEFAULT_SENSITIVE_FIELDS, DEFAULT_SENSITIVE_HEADERS, type DebugContextOptions, type ErrorContext, type GitContext, type Incident, type RequestContext, type RuntimeContext, type SystemContext, type ToFileOptions, capture, collectError, collectGit, collectRuntime, collectSystem, DebugContext as default, getOptions, init, middleware, redactBody, redactHeaders, toConsole, toFile, toJSON, toFile$1 as writeIncidentToFile };
@@ -0,0 +1,332 @@
1
+ /**
2
+ * @module types
3
+ * Core type definitions for DebugContext incidents.
4
+ */
5
+ /** HTTP request context captured at the time of the error. */
6
+ interface RequestContext {
7
+ /** HTTP method (GET, POST, …) */
8
+ method: string;
9
+ /** Full request URL including query string */
10
+ url: string;
11
+ /** Express-style named route params, e.g. { id: "42" } */
12
+ params: Record<string, string>;
13
+ /** Parsed query-string parameters */
14
+ query: Record<string, string | string[]>;
15
+ /** Request body — sensitive fields are redacted */
16
+ body: unknown;
17
+ /** Selected headers — auth / cookie values are redacted */
18
+ headers: Record<string, string>;
19
+ /** Client IP address */
20
+ ip: string;
21
+ /** User-Agent string */
22
+ userAgent: string;
23
+ }
24
+ /** Node.js runtime context at the time of the error. */
25
+ interface RuntimeContext {
26
+ /** ISO-8601 timestamp */
27
+ timestamp: string;
28
+ /** NODE_ENV value, defaults to "development" */
29
+ environment: string;
30
+ /** process.version */
31
+ nodeVersion: string;
32
+ /** process.pid */
33
+ pid: number;
34
+ /** os.hostname() */
35
+ hostname: string;
36
+ /** process.uptime() in seconds */
37
+ uptimeSeconds: number;
38
+ /** process.cwd() */
39
+ workingDirectory: string;
40
+ }
41
+ /** Operating-system / process memory context. */
42
+ interface SystemContext {
43
+ /** process.memoryUsage() */
44
+ memory: {
45
+ rss: number;
46
+ heapTotal: number;
47
+ heapUsed: number;
48
+ external: number;
49
+ arrayBuffers: number;
50
+ };
51
+ /** Heap usage as a percentage 0-100 */
52
+ heapUsagePercent: number;
53
+ /** os.loadavg() — [1m, 5m, 15m] */
54
+ cpuLoadAvg: [number, number, number];
55
+ /** os.platform() */
56
+ platform: string;
57
+ /** os.arch() */
58
+ arch: string;
59
+ /** Total system memory in bytes */
60
+ totalMemory: number;
61
+ /** Free system memory in bytes */
62
+ freeMemory: number;
63
+ }
64
+ /** Git / package metadata resolved at startup. */
65
+ interface GitContext {
66
+ /** Short (8-char) commit hash, or "unknown" */
67
+ commitHash: string;
68
+ /** Current branch name, or "unknown" */
69
+ branch: string;
70
+ /** version field from the nearest package.json */
71
+ packageVersion: string;
72
+ }
73
+ /** Serialisable error context. */
74
+ interface ErrorContext {
75
+ /** Error constructor name */
76
+ name: string;
77
+ /** Error message */
78
+ message: string;
79
+ /** Full stack trace */
80
+ stack: string | undefined;
81
+ /** Serialised error.cause if present */
82
+ cause: unknown;
83
+ }
84
+ /**
85
+ * A fully structured debugging snapshot produced whenever an unhandled error
86
+ * or a caught framework error occurs.
87
+ */
88
+ interface Incident {
89
+ /** Unique ID for this incident (UUID v4) */
90
+ incidentId: string;
91
+ /** ISO-8601 timestamp — duplicated here for quick top-level access */
92
+ timestamp: string;
93
+ /** HTTP request that was in-flight when the error occurred (may be null) */
94
+ request: RequestContext | null;
95
+ /** Node.js runtime snapshot */
96
+ runtime: RuntimeContext;
97
+ /** System resource snapshot */
98
+ system: SystemContext;
99
+ /** Git / package metadata */
100
+ git: GitContext;
101
+ /** Serialised error */
102
+ error: ErrorContext;
103
+ }
104
+ /**
105
+ * Options accepted by `DebugContext.init()`.
106
+ * Everything is optional — the SDK works with zero configuration.
107
+ */
108
+ interface DebugContextOptions {
109
+ /**
110
+ * Additional header names whose values should be redacted.
111
+ * Merged with the built-in sensitive header list.
112
+ */
113
+ sensitiveHeaders?: string[];
114
+ /**
115
+ * Additional body field names whose values should be redacted.
116
+ * Merged with the built-in sensitive field list.
117
+ */
118
+ sensitiveFields?: string[];
119
+ /**
120
+ * Called after each incident is captured.
121
+ * Use this hook to ship incidents to your own storage / alerting.
122
+ *
123
+ * @example
124
+ * DebugContext.init({
125
+ * onIncident: (incident) => myStorage.save(incident),
126
+ * });
127
+ */
128
+ onIncident?: (incident: Incident) => void | Promise<void>;
129
+ /**
130
+ * When true, DebugContext attaches a global `uncaughtException` +
131
+ * `unhandledRejection` listener. Defaults to `true`.
132
+ */
133
+ captureGlobalErrors?: boolean;
134
+ }
135
+
136
+ interface ToFileOptions {
137
+ /**
138
+ * Path to the output file.
139
+ * @default "incidents.ndjson" (relative to process.cwd())
140
+ */
141
+ path?: string;
142
+ /**
143
+ * When `true`, creates parent directories if they don't exist.
144
+ * @default true
145
+ */
146
+ mkdirp?: boolean;
147
+ }
148
+ /**
149
+ * Appends an incident as a single JSON line to an NDJSON file.
150
+ *
151
+ * - Safe to call from multiple processes (append is atomic on most OSes).
152
+ * - Synchronous by design so it can be called inside `onIncident` without
153
+ * worrying about buffering or unhandled promise rejections.
154
+ *
155
+ * @param incident - The incident to write.
156
+ * @param options - Output options.
157
+ *
158
+ * @example
159
+ * ```ts
160
+ * // Write to the default path (incidents.ndjson)
161
+ * DebugContext.toFile(incident);
162
+ *
163
+ * // Write to a custom path
164
+ * DebugContext.toFile(incident, { path: 'logs/incidents.ndjson' });
165
+ * ```
166
+ */
167
+ declare function toFile$1(incident: Incident, options?: ToFileOptions): void;
168
+
169
+ /**
170
+ * Initialises DebugContext with optional configuration.
171
+ *
172
+ * Call once at application startup — before your Express app starts
173
+ * accepting requests.
174
+ *
175
+ * @example
176
+ * ```ts
177
+ * import DebugContext from '@debugcontext/core';
178
+ *
179
+ * DebugContext.init({ onIncident: (i) => console.log(i) });
180
+ * ```
181
+ */
182
+ declare function init(userOptions?: DebugContextOptions): void;
183
+ /**
184
+ * Captures an error (and an optional request context provided by a framework
185
+ * adapter) into a structured Incident.
186
+ *
187
+ * @param error - The thrown value.
188
+ * @param request - Optional request context from a framework adapter.
189
+ * @returns The captured Incident.
190
+ *
191
+ * @example
192
+ * ```ts
193
+ * try {
194
+ * riskyOperation();
195
+ * } catch (err) {
196
+ * const incident = DebugContext.capture(err);
197
+ * DebugContext.toConsole(incident);
198
+ * }
199
+ * ```
200
+ */
201
+ declare function capture(error: unknown, request?: RequestContext | null): Incident;
202
+ /**
203
+ * Returns the most recently captured Incident as a JSON string.
204
+ *
205
+ * @param incident - Incident to serialise. Defaults to the last captured one.
206
+ * @returns Pretty-printed JSON string, or `null` if no incident has been captured.
207
+ */
208
+ declare function toJSON(incident?: Incident): string | null;
209
+ /**
210
+ * Prints the incident to the console in a human-readable format.
211
+ *
212
+ * @param incident - Incident to print. Defaults to the last captured one.
213
+ */
214
+ declare function toConsole(incident?: Incident): void;
215
+ /**
216
+ * Appends the incident to a newline-delimited JSON (NDJSON) file.
217
+ * Creates the file and parent directories if they don't exist.
218
+ *
219
+ * @param incident - Incident to write. Defaults to the last captured one.
220
+ * @param options - `{ path?: string }` — defaults to `"incidents.ndjson"`.
221
+ *
222
+ * @example
223
+ * ```ts
224
+ * DebugContext.init({
225
+ * onIncident: (i) => DebugContext.toFile(i, { path: 'logs/incidents.ndjson' }),
226
+ * });
227
+ * ```
228
+ */
229
+ declare function toFile(incident?: Incident, options?: ToFileOptions): void;
230
+ /**
231
+ * Returns a framework-agnostic capture function pre-bound to the current
232
+ * options. Useful when building custom adapters.
233
+ *
234
+ * For Express, use `@debugcontext/express` instead.
235
+ *
236
+ * @example
237
+ * ```ts
238
+ * // In a custom adapter:
239
+ * const mw = DebugContext.middleware();
240
+ * app.use((err, req, res, next) => {
241
+ * const requestCtx = buildRequestCtx(req);
242
+ * mw(err, requestCtx);
243
+ * next(err);
244
+ * });
245
+ * ```
246
+ */
247
+ declare function middleware(): (error: unknown, request?: RequestContext | null) => Incident;
248
+ /**
249
+ * Returns the current SDK options (useful for adapters).
250
+ * @internal
251
+ */
252
+ declare function getOptions(): Required<DebugContextOptions>;
253
+ /**
254
+ * The DebugContext SDK.
255
+ *
256
+ * @example
257
+ * ```ts
258
+ * import DebugContext from '@debugcontext/core';
259
+ *
260
+ * DebugContext.init();
261
+ * ```
262
+ */
263
+ declare const DebugContext: {
264
+ readonly init: typeof init;
265
+ readonly capture: typeof capture;
266
+ readonly toJSON: typeof toJSON;
267
+ readonly toConsole: typeof toConsole;
268
+ readonly toFile: typeof toFile;
269
+ readonly middleware: typeof middleware;
270
+ /** @internal used by framework adapters */
271
+ readonly getOptions: typeof getOptions;
272
+ };
273
+
274
+ /**
275
+ * @module collectors/error
276
+ * Serialises a thrown value into a structured ErrorContext.
277
+ */
278
+
279
+ /**
280
+ * Converts any thrown value into a structured, serialisable ErrorContext.
281
+ *
282
+ * Handles:
283
+ * - Standard `Error` instances (including subclasses).
284
+ * - Errors with a `.cause` (ES2022 error chaining).
285
+ * - Non-Error throws (strings, objects, etc.).
286
+ */
287
+ declare function collectError(thrown: unknown): ErrorContext;
288
+
289
+ /**
290
+ * Returns the Git context. Resolution runs once and is then cached for the
291
+ * lifetime of the process.
292
+ */
293
+ declare function collectGit(): GitContext;
294
+
295
+ /**
296
+ * Captures a snapshot of the current Node.js runtime environment.
297
+ */
298
+ declare function collectRuntime(): RuntimeContext;
299
+
300
+ /**
301
+ * Captures a snapshot of current system resource usage.
302
+ */
303
+ declare function collectSystem(): SystemContext;
304
+
305
+ /**
306
+ * @module redact
307
+ * Utilities for scrubbing sensitive data from headers and request bodies
308
+ * before they are included in an Incident.
309
+ */
310
+ /** Header names that are always redacted (case-insensitive comparison). */
311
+ declare const DEFAULT_SENSITIVE_HEADERS: readonly string[];
312
+ /** Body / object field names that are always redacted (case-insensitive). */
313
+ declare const DEFAULT_SENSITIVE_FIELDS: readonly string[];
314
+ /**
315
+ * Returns a copy of `headers` where sensitive values are replaced with
316
+ * `"[REDACTED]"`.
317
+ *
318
+ * @param headers - Raw header map (values may be string or string[]).
319
+ * @param extraFields - Caller-supplied additional header names to redact.
320
+ */
321
+ declare function redactHeaders(headers: Record<string, string | string[] | undefined>, extraFields?: string[]): Record<string, string>;
322
+ /**
323
+ * Deeply walks `body` (plain objects / arrays) and replaces the *values* of
324
+ * sensitive keys with `"[REDACTED]"`. Non-plain-object values are returned
325
+ * as-is (e.g. strings, numbers, Buffers).
326
+ *
327
+ * @param body - The request body to sanitise.
328
+ * @param extraFields - Caller-supplied additional field names to redact.
329
+ */
330
+ declare function redactBody(body: unknown, extraFields?: string[]): unknown;
331
+
332
+ export { DEFAULT_SENSITIVE_FIELDS, DEFAULT_SENSITIVE_HEADERS, type DebugContextOptions, type ErrorContext, type GitContext, type Incident, type RequestContext, type RuntimeContext, type SystemContext, type ToFileOptions, capture, collectError, collectGit, collectRuntime, collectSystem, DebugContext as default, getOptions, init, middleware, redactBody, redactHeaders, toConsole, toFile, toJSON, toFile$1 as writeIncidentToFile };