@geekmidas/telescope 1.1.1 → 10.0.0-alpha.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.
Files changed (167) hide show
  1. package/README.md +14 -4
  2. package/dist/{hono-Bz9PQQzj.mjs → hono-Bw-ey6CT.mjs} +2 -2
  3. package/dist/{hono-Bz9PQQzj.mjs.map → hono-Bw-ey6CT.mjs.map} +1 -1
  4. package/dist/{hono-Z_JIICmt.cjs → hono-CPHX7FAm.cjs} +2 -2
  5. package/dist/{hono-Z_JIICmt.cjs.map → hono-CPHX7FAm.cjs.map} +1 -1
  6. package/dist/{http-Crsriv32.mjs → http-BIvr0YdI.mjs} +1 -1
  7. package/dist/{http-Crsriv32.mjs.map → http-BIvr0YdI.mjs.map} +1 -1
  8. package/dist/{http-JycFRfSe.cjs → http-BsqmhurZ.cjs} +1 -1
  9. package/dist/{http-JycFRfSe.cjs.map → http-BsqmhurZ.cjs.map} +1 -1
  10. package/dist/{http-D5kn3_Mt.d.mts → http-DULM1u2L.d.cts} +3 -3
  11. package/dist/{http-D5kn3_Mt.d.mts.map → http-DULM1u2L.d.cts.map} +1 -1
  12. package/dist/{http-Dvca6fC3.d.cts → http-GB-Nlvwc.d.mts} +3 -3
  13. package/dist/{http-Dvca6fC3.d.cts.map → http-GB-Nlvwc.d.mts.map} +1 -1
  14. package/dist/instrumentation/hono.cjs +2 -2
  15. package/dist/instrumentation/hono.mjs +2 -2
  16. package/dist/instrumentation/http.cjs +1 -1
  17. package/dist/instrumentation/http.d.cts +1 -1
  18. package/dist/instrumentation/http.d.mts +1 -1
  19. package/dist/instrumentation/http.mjs +1 -1
  20. package/dist/instrumentation/index.cjs +5 -5
  21. package/dist/instrumentation/index.d.cts +3 -3
  22. package/dist/instrumentation/index.d.mts +3 -3
  23. package/dist/instrumentation/index.mjs +5 -5
  24. package/dist/instrumentation/middleware.cjs +2 -2
  25. package/dist/instrumentation/middleware.d.cts +1 -1
  26. package/dist/instrumentation/middleware.d.mts +1 -1
  27. package/dist/instrumentation/middleware.mjs +2 -2
  28. package/dist/instrumentation/otel.cjs +2 -2
  29. package/dist/instrumentation/otel.d.cts +1 -1
  30. package/dist/instrumentation/otel.d.mts +1 -1
  31. package/dist/instrumentation/otel.mjs +2 -2
  32. package/dist/instrumentation/setup.cjs +1 -1
  33. package/dist/instrumentation/setup.mjs +1 -1
  34. package/dist/logger/console.d.cts.map +1 -1
  35. package/dist/{middleware-D3v5SnSs.cjs → middleware-Bcq6XXGG.cjs} +3 -3
  36. package/dist/middleware-Bcq6XXGG.cjs.map +1 -0
  37. package/dist/{middleware-Dy1ctr2N.mjs → middleware-D1XEHvyy.mjs} +3 -3
  38. package/dist/middleware-D1XEHvyy.mjs.map +1 -0
  39. package/dist/{middleware-CA84nsNN.d.cts → middleware-PeyS-9Ny.d.cts} +2 -2
  40. package/dist/{middleware-CA84nsNN.d.cts.map → middleware-PeyS-9Ny.d.cts.map} +1 -1
  41. package/dist/{middleware-DAceVpfw.d.mts → middleware-oHvo_ZgU.d.mts} +2 -2
  42. package/dist/{middleware-DAceVpfw.d.mts.map → middleware-oHvo_ZgU.d.mts.map} +1 -1
  43. package/dist/{otel-DPKNyJ0t.mjs → otel-B9bNoeZ2.mjs} +4 -4
  44. package/dist/otel-B9bNoeZ2.mjs.map +1 -0
  45. package/dist/{otel-1bJPb2Z7.d.mts → otel-Bk89b1lX.d.cts} +3 -3
  46. package/dist/{otel-1bJPb2Z7.d.mts.map → otel-Bk89b1lX.d.cts.map} +1 -1
  47. package/dist/{otel-DuiBeBPU.cjs → otel-BzjOtVxZ.cjs} +4 -4
  48. package/dist/otel-BzjOtVxZ.cjs.map +1 -0
  49. package/dist/{otel-SBVoVEHr.d.cts → otel-lPMsM26e.d.mts} +3 -3
  50. package/dist/{otel-SBVoVEHr.d.cts.map → otel-lPMsM26e.d.mts.map} +1 -1
  51. package/dist/otlp/hono.cjs +3 -3
  52. package/dist/otlp/hono.mjs +3 -3
  53. package/dist/otlp/index.cjs +3 -3
  54. package/dist/otlp/index.mjs +3 -3
  55. package/dist/otlp/receiver.cjs +3 -3
  56. package/dist/otlp/receiver.mjs +3 -3
  57. package/dist/otlp/transformer.cjs +2 -2
  58. package/dist/otlp/transformer.mjs +2 -2
  59. package/dist/otlp/types.cjs +1 -1
  60. package/dist/otlp/types.mjs +1 -1
  61. package/dist/{receiver-q4f7eirs.mjs → receiver-D46dfkYI.mjs} +2 -2
  62. package/dist/{receiver-q4f7eirs.mjs.map → receiver-D46dfkYI.mjs.map} +1 -1
  63. package/dist/{receiver-BW_4go_X.cjs → receiver-slCoAFat.cjs} +2 -2
  64. package/dist/{receiver-BW_4go_X.cjs.map → receiver-slCoAFat.cjs.map} +1 -1
  65. package/dist/{setup-BhCp2LUp.mjs → setup-DC9JMEYZ.mjs} +1 -1
  66. package/dist/{setup-BhCp2LUp.mjs.map → setup-DC9JMEYZ.mjs.map} +1 -1
  67. package/dist/{setup-_uT4L_x5.cjs → setup-DufxQpi9.cjs} +1 -1
  68. package/dist/{setup-_uT4L_x5.cjs.map → setup-DufxQpi9.cjs.map} +1 -1
  69. package/dist/storage/kysely.cjs +48 -38
  70. package/dist/storage/kysely.cjs.map +1 -1
  71. package/dist/storage/kysely.d.cts +29 -9
  72. package/dist/storage/kysely.d.cts.map +1 -1
  73. package/dist/storage/kysely.d.mts +29 -9
  74. package/dist/storage/kysely.d.mts.map +1 -1
  75. package/dist/storage/kysely.mjs +48 -38
  76. package/dist/storage/kysely.mjs.map +1 -1
  77. package/dist/tracing-BX8uY2nR.d.cts.map +1 -1
  78. package/dist/tracing-PnECEbEu.d.mts.map +1 -1
  79. package/dist/{transformer-CFrJQkUg.mjs → transformer-CFQ4WFk6.mjs} +2 -2
  80. package/dist/{transformer-CFrJQkUg.mjs.map → transformer-CFQ4WFk6.mjs.map} +1 -1
  81. package/dist/{transformer-DvDYyFRQ.cjs → transformer-Csl6fbgv.cjs} +2 -2
  82. package/dist/{transformer-DvDYyFRQ.cjs.map → transformer-Csl6fbgv.cjs.map} +1 -1
  83. package/dist/types-B1EIa_cQ.d.mts.map +1 -1
  84. package/dist/{types-BBeTDpHr.cjs → types-BMiHgsi4.cjs} +1 -1
  85. package/dist/{types-BBeTDpHr.cjs.map → types-BMiHgsi4.cjs.map} +1 -1
  86. package/dist/{types-CXYLhG_G.mjs → types-Cj59nqy7.mjs} +1 -1
  87. package/dist/{types-CXYLhG_G.mjs.map → types-Cj59nqy7.mjs.map} +1 -1
  88. package/dist/types-l7Rlb5Mg.d.cts.map +1 -1
  89. package/package.json +6 -3
  90. package/CHANGELOG.md +0 -51
  91. package/dist/middleware-D3v5SnSs.cjs.map +0 -1
  92. package/dist/middleware-Dy1ctr2N.mjs.map +0 -1
  93. package/dist/otel-DPKNyJ0t.mjs.map +0 -1
  94. package/dist/otel-DuiBeBPU.cjs.map +0 -1
  95. package/src/Telescope.ts +0 -561
  96. package/src/__tests__/Telescope.spec.ts +0 -438
  97. package/src/__tests__/pino-transport.spec.ts +0 -115
  98. package/src/__tests__/redact.spec.ts +0 -336
  99. package/src/adapters/__tests__/lambda.spec.ts +0 -318
  100. package/src/adapters/__tests__/middy.spec.ts +0 -741
  101. package/src/adapters/index.ts +0 -22
  102. package/src/adapters/lambda.ts +0 -432
  103. package/src/adapters/middy.ts +0 -402
  104. package/src/adapters/types.ts +0 -181
  105. package/src/core.ts +0 -51
  106. package/src/index.ts +0 -34
  107. package/src/instrumentation/__tests__/core.spec.ts +0 -248
  108. package/src/instrumentation/__tests__/hono.spec.ts +0 -348
  109. package/src/instrumentation/__tests__/middleware.spec.ts +0 -528
  110. package/src/instrumentation/__tests__/otel.spec.ts +0 -291
  111. package/src/instrumentation/__tests__/tracing.spec.ts +0 -208
  112. package/src/instrumentation/core.ts +0 -228
  113. package/src/instrumentation/hono.ts +0 -270
  114. package/src/instrumentation/http.ts +0 -306
  115. package/src/instrumentation/index.ts +0 -90
  116. package/src/instrumentation/middleware.ts +0 -297
  117. package/src/instrumentation/otel.ts +0 -271
  118. package/src/instrumentation/setup.ts +0 -246
  119. package/src/instrumentation/tracing.ts +0 -145
  120. package/src/logger/__tests__/console.spec.ts +0 -366
  121. package/src/logger/__tests__/pino.spec.ts +0 -217
  122. package/src/logger/console.ts +0 -230
  123. package/src/logger/pino.ts +0 -201
  124. package/src/metrics/MetricsAggregator.ts +0 -555
  125. package/src/metrics/__tests__/MetricsAggregator.spec.ts +0 -298
  126. package/src/metrics/index.ts +0 -2
  127. package/src/metrics/storage/InMemoryMetricsStorage.ts +0 -380
  128. package/src/metrics/storage/MetricsStorage.ts +0 -74
  129. package/src/metrics/storage/index.ts +0 -3
  130. package/src/metrics/storage/types.ts +0 -243
  131. package/src/otlp/__tests__/receiver.spec.ts +0 -367
  132. package/src/otlp/__tests__/transformer.spec.ts +0 -455
  133. package/src/otlp/hono.ts +0 -120
  134. package/src/otlp/index.ts +0 -22
  135. package/src/otlp/receiver.ts +0 -162
  136. package/src/otlp/transformer.ts +0 -367
  137. package/src/otlp/types.ts +0 -364
  138. package/src/redact.ts +0 -116
  139. package/src/server/__tests__/hono.spec.ts +0 -814
  140. package/src/server/hono.ts +0 -442
  141. package/src/storage/__tests__/kysely.spec.ts +0 -715
  142. package/src/storage/__tests__/memory.spec.ts +0 -694
  143. package/src/storage/kysely.ts +0 -599
  144. package/src/storage/memory.ts +0 -204
  145. package/src/types.ts +0 -447
  146. package/src/ui-assets.ts +0 -40
  147. package/tsconfig.json +0 -9
  148. package/ui/CHANGELOG.md +0 -7
  149. package/ui/index.html +0 -12
  150. package/ui/node_modules/.bin/tsc +0 -21
  151. package/ui/node_modules/.bin/tsserver +0 -21
  152. package/ui/node_modules/.bin/vite +0 -21
  153. package/ui/package.json +0 -24
  154. package/ui/src/App.tsx +0 -595
  155. package/ui/src/api.ts +0 -88
  156. package/ui/src/components/ExceptionDetail.tsx +0 -100
  157. package/ui/src/components/FilterBar.tsx +0 -162
  158. package/ui/src/components/LogDetail.tsx +0 -91
  159. package/ui/src/components/RequestDetail.tsx +0 -143
  160. package/ui/src/main.tsx +0 -10
  161. package/ui/src/styles.css +0 -11
  162. package/ui/src/types.ts +0 -63
  163. package/ui/src/vite-env.d.ts +0 -1
  164. package/ui/src/vite-plugin-gkm-config.ts +0 -54
  165. package/ui/tsconfig.json +0 -20
  166. package/ui/tsconfig.tsbuildinfo +0 -1
  167. package/ui/vite.config.ts +0 -13
package/src/otlp/types.ts DELETED
@@ -1,364 +0,0 @@
1
- /**
2
- * OTLP JSON types based on OpenTelemetry Protocol specification.
3
- * These types represent the JSON encoding of OTLP protobuf messages.
4
- * @see https://opentelemetry.io/docs/specs/otlp/
5
- */
6
-
7
- // ============================================
8
- // Common Types
9
- // ============================================
10
-
11
- /**
12
- * Key-value pair for attributes
13
- */
14
- export interface KeyValue {
15
- key: string;
16
- value: AnyValue;
17
- }
18
-
19
- /**
20
- * Any value type (string, bool, int, double, array, kvlist, bytes)
21
- */
22
- export interface AnyValue {
23
- stringValue?: string;
24
- boolValue?: boolean;
25
- intValue?: string; // int64 as string
26
- doubleValue?: number;
27
- arrayValue?: ArrayValue;
28
- kvlistValue?: KeyValueList;
29
- bytesValue?: string; // base64 encoded
30
- }
31
-
32
- export interface ArrayValue {
33
- values: AnyValue[];
34
- }
35
-
36
- export interface KeyValueList {
37
- values: KeyValue[];
38
- }
39
-
40
- /**
41
- * Resource represents the entity producing telemetry
42
- */
43
- export interface Resource {
44
- attributes?: KeyValue[];
45
- droppedAttributesCount?: number;
46
- }
47
-
48
- /**
49
- * InstrumentationScope represents the instrumentation library
50
- */
51
- export interface InstrumentationScope {
52
- name: string;
53
- version?: string;
54
- attributes?: KeyValue[];
55
- droppedAttributesCount?: number;
56
- }
57
-
58
- // ============================================
59
- // Trace Types
60
- // ============================================
61
-
62
- /**
63
- * Root message for trace export
64
- */
65
- export interface ExportTraceServiceRequest {
66
- resourceSpans?: ResourceSpans[];
67
- }
68
-
69
- export interface ResourceSpans {
70
- resource?: Resource;
71
- scopeSpans?: ScopeSpans[];
72
- schemaUrl?: string;
73
- }
74
-
75
- export interface ScopeSpans {
76
- scope?: InstrumentationScope;
77
- spans?: Span[];
78
- schemaUrl?: string;
79
- }
80
-
81
- export interface Span {
82
- traceId: string; // hex encoded 16 bytes
83
- spanId: string; // hex encoded 8 bytes
84
- traceState?: string;
85
- parentSpanId?: string; // hex encoded 8 bytes
86
- flags?: number;
87
- name: string;
88
- kind?: SpanKind;
89
- startTimeUnixNano: string; // uint64 as string
90
- endTimeUnixNano: string; // uint64 as string
91
- attributes?: KeyValue[];
92
- droppedAttributesCount?: number;
93
- events?: SpanEvent[];
94
- droppedEventsCount?: number;
95
- links?: SpanLink[];
96
- droppedLinksCount?: number;
97
- status?: SpanStatus;
98
- }
99
-
100
- export enum SpanKind {
101
- SPAN_KIND_UNSPECIFIED = 0,
102
- SPAN_KIND_INTERNAL = 1,
103
- SPAN_KIND_SERVER = 2,
104
- SPAN_KIND_CLIENT = 3,
105
- SPAN_KIND_PRODUCER = 4,
106
- SPAN_KIND_CONSUMER = 5,
107
- }
108
-
109
- export interface SpanEvent {
110
- timeUnixNano: string;
111
- name: string;
112
- attributes?: KeyValue[];
113
- droppedAttributesCount?: number;
114
- }
115
-
116
- export interface SpanLink {
117
- traceId: string;
118
- spanId: string;
119
- traceState?: string;
120
- attributes?: KeyValue[];
121
- droppedAttributesCount?: number;
122
- flags?: number;
123
- }
124
-
125
- export interface SpanStatus {
126
- message?: string;
127
- code?: SpanStatusCode;
128
- }
129
-
130
- export enum SpanStatusCode {
131
- STATUS_CODE_UNSET = 0,
132
- STATUS_CODE_OK = 1,
133
- STATUS_CODE_ERROR = 2,
134
- }
135
-
136
- // ============================================
137
- // Log Types
138
- // ============================================
139
-
140
- /**
141
- * Root message for log export
142
- */
143
- export interface ExportLogsServiceRequest {
144
- resourceLogs?: ResourceLogs[];
145
- }
146
-
147
- export interface ResourceLogs {
148
- resource?: Resource;
149
- scopeLogs?: ScopeLogs[];
150
- schemaUrl?: string;
151
- }
152
-
153
- export interface ScopeLogs {
154
- scope?: InstrumentationScope;
155
- logRecords?: LogRecord[];
156
- schemaUrl?: string;
157
- }
158
-
159
- export interface LogRecord {
160
- timeUnixNano?: string;
161
- observedTimeUnixNano: string;
162
- severityNumber?: SeverityNumber;
163
- severityText?: string;
164
- body?: AnyValue;
165
- attributes?: KeyValue[];
166
- droppedAttributesCount?: number;
167
- flags?: number;
168
- traceId?: string;
169
- spanId?: string;
170
- }
171
-
172
- export enum SeverityNumber {
173
- SEVERITY_NUMBER_UNSPECIFIED = 0,
174
- SEVERITY_NUMBER_TRACE = 1,
175
- SEVERITY_NUMBER_TRACE2 = 2,
176
- SEVERITY_NUMBER_TRACE3 = 3,
177
- SEVERITY_NUMBER_TRACE4 = 4,
178
- SEVERITY_NUMBER_DEBUG = 5,
179
- SEVERITY_NUMBER_DEBUG2 = 6,
180
- SEVERITY_NUMBER_DEBUG3 = 7,
181
- SEVERITY_NUMBER_DEBUG4 = 8,
182
- SEVERITY_NUMBER_INFO = 9,
183
- SEVERITY_NUMBER_INFO2 = 10,
184
- SEVERITY_NUMBER_INFO3 = 11,
185
- SEVERITY_NUMBER_INFO4 = 12,
186
- SEVERITY_NUMBER_WARN = 13,
187
- SEVERITY_NUMBER_WARN2 = 14,
188
- SEVERITY_NUMBER_WARN3 = 15,
189
- SEVERITY_NUMBER_WARN4 = 16,
190
- SEVERITY_NUMBER_ERROR = 17,
191
- SEVERITY_NUMBER_ERROR2 = 18,
192
- SEVERITY_NUMBER_ERROR3 = 19,
193
- SEVERITY_NUMBER_ERROR4 = 20,
194
- SEVERITY_NUMBER_FATAL = 21,
195
- SEVERITY_NUMBER_FATAL2 = 22,
196
- SEVERITY_NUMBER_FATAL3 = 23,
197
- SEVERITY_NUMBER_FATAL4 = 24,
198
- }
199
-
200
- // ============================================
201
- // Metrics Types
202
- // ============================================
203
-
204
- /**
205
- * Root message for metrics export
206
- */
207
- export interface ExportMetricsServiceRequest {
208
- resourceMetrics?: ResourceMetrics[];
209
- }
210
-
211
- export interface ResourceMetrics {
212
- resource?: Resource;
213
- scopeMetrics?: ScopeMetrics[];
214
- schemaUrl?: string;
215
- }
216
-
217
- export interface ScopeMetrics {
218
- scope?: InstrumentationScope;
219
- metrics?: Metric[];
220
- schemaUrl?: string;
221
- }
222
-
223
- export interface Metric {
224
- name: string;
225
- description?: string;
226
- unit?: string;
227
- metadata?: KeyValue[];
228
- gauge?: Gauge;
229
- sum?: Sum;
230
- histogram?: Histogram;
231
- exponentialHistogram?: ExponentialHistogram;
232
- summary?: Summary;
233
- }
234
-
235
- export interface Gauge {
236
- dataPoints: NumberDataPoint[];
237
- }
238
-
239
- export interface Sum {
240
- dataPoints: NumberDataPoint[];
241
- aggregationTemporality: AggregationTemporality;
242
- isMonotonic?: boolean;
243
- }
244
-
245
- export interface Histogram {
246
- dataPoints: HistogramDataPoint[];
247
- aggregationTemporality: AggregationTemporality;
248
- }
249
-
250
- export interface ExponentialHistogram {
251
- dataPoints: ExponentialHistogramDataPoint[];
252
- aggregationTemporality: AggregationTemporality;
253
- }
254
-
255
- export interface Summary {
256
- dataPoints: SummaryDataPoint[];
257
- }
258
-
259
- export enum AggregationTemporality {
260
- AGGREGATION_TEMPORALITY_UNSPECIFIED = 0,
261
- AGGREGATION_TEMPORALITY_DELTA = 1,
262
- AGGREGATION_TEMPORALITY_CUMULATIVE = 2,
263
- }
264
-
265
- export interface NumberDataPoint {
266
- attributes?: KeyValue[];
267
- startTimeUnixNano?: string;
268
- timeUnixNano: string;
269
- asDouble?: number;
270
- asInt?: string;
271
- exemplars?: Exemplar[];
272
- flags?: number;
273
- }
274
-
275
- export interface HistogramDataPoint {
276
- attributes?: KeyValue[];
277
- startTimeUnixNano?: string;
278
- timeUnixNano: string;
279
- count: string;
280
- sum?: number;
281
- bucketCounts?: string[];
282
- explicitBounds?: number[];
283
- exemplars?: Exemplar[];
284
- flags?: number;
285
- min?: number;
286
- max?: number;
287
- }
288
-
289
- export interface ExponentialHistogramDataPoint {
290
- attributes?: KeyValue[];
291
- startTimeUnixNano?: string;
292
- timeUnixNano: string;
293
- count: string;
294
- sum?: number;
295
- scale?: number;
296
- zeroCount?: string;
297
- positive?: Buckets;
298
- negative?: Buckets;
299
- flags?: number;
300
- exemplars?: Exemplar[];
301
- min?: number;
302
- max?: number;
303
- zeroThreshold?: number;
304
- }
305
-
306
- export interface Buckets {
307
- offset?: number;
308
- bucketCounts?: string[];
309
- }
310
-
311
- export interface SummaryDataPoint {
312
- attributes?: KeyValue[];
313
- startTimeUnixNano?: string;
314
- timeUnixNano: string;
315
- count: string;
316
- sum?: number;
317
- quantileValues?: ValueAtQuantile[];
318
- flags?: number;
319
- }
320
-
321
- export interface ValueAtQuantile {
322
- quantile: number;
323
- value: number;
324
- }
325
-
326
- export interface Exemplar {
327
- filteredAttributes?: KeyValue[];
328
- timeUnixNano: string;
329
- asDouble?: number;
330
- asInt?: string;
331
- spanId?: string;
332
- traceId?: string;
333
- }
334
-
335
- // ============================================
336
- // Response Types
337
- // ============================================
338
-
339
- export interface ExportTraceServiceResponse {
340
- partialSuccess?: ExportTracePartialSuccess;
341
- }
342
-
343
- export interface ExportTracePartialSuccess {
344
- rejectedSpans?: string;
345
- errorMessage?: string;
346
- }
347
-
348
- export interface ExportLogsServiceResponse {
349
- partialSuccess?: ExportLogsPartialSuccess;
350
- }
351
-
352
- export interface ExportLogsPartialSuccess {
353
- rejectedLogRecords?: string;
354
- errorMessage?: string;
355
- }
356
-
357
- export interface ExportMetricsServiceResponse {
358
- partialSuccess?: ExportMetricsPartialSuccess;
359
- }
360
-
361
- export interface ExportMetricsPartialSuccess {
362
- rejectedDataPoints?: string;
363
- errorMessage?: string;
364
- }
package/src/redact.ts DELETED
@@ -1,116 +0,0 @@
1
- import { DEFAULT_REDACT_PATHS as BASE_REDACT_PATHS } from '@geekmidas/logger/redact';
2
- import pinoRedact from '@pinojs/redact';
3
- import type { TelescopeRedactOptions } from './types';
4
-
5
- /**
6
- * Telescope-specific redaction paths for HTTP request/response data.
7
- * These extend the base paths from @geekmidas/logger.
8
- */
9
- const TELESCOPE_SPECIFIC_PATHS: string[] = [
10
- // Response headers (telescope-specific)
11
- 'responseHeaders.set-cookie',
12
- 'responseHeaders.Set-Cookie',
13
-
14
- // Request body fields
15
- 'body.password',
16
- 'body.token',
17
- 'body.accessToken',
18
- 'body.refreshToken',
19
- 'body.apiKey',
20
- 'body.secret',
21
- 'body.creditCard',
22
- 'body.cardNumber',
23
- 'body.cvv',
24
- 'body.ssn',
25
-
26
- // Nested body patterns (wildcards)
27
- 'body.*.password',
28
- 'body.*.token',
29
- 'body.*.secret',
30
- 'body.*.apiKey',
31
-
32
- // Response body fields
33
- 'responseBody.password',
34
- 'responseBody.token',
35
- 'responseBody.accessToken',
36
- 'responseBody.refreshToken',
37
- 'responseBody.secret',
38
- 'responseBody.*.password',
39
- 'responseBody.*.token',
40
- 'responseBody.*.secret',
41
-
42
- // Query parameters
43
- 'query.token',
44
- 'query.api_key',
45
- 'query.apiKey',
46
- 'query.access_token',
47
- 'query.secret',
48
-
49
- // Log context patterns
50
- 'context.password',
51
- 'context.token',
52
- 'context.secret',
53
- 'context.apiKey',
54
- 'context.*.password',
55
- 'context.*.token',
56
- 'context.*.secret',
57
- ];
58
-
59
- /**
60
- * Combined default paths for Telescope redaction.
61
- * Includes base paths from @geekmidas/logger plus telescope-specific HTTP paths.
62
- */
63
- export const DEFAULT_REDACT_PATHS: string[] = [
64
- ...BASE_REDACT_PATHS,
65
- ...TELESCOPE_SPECIFIC_PATHS,
66
- ];
67
-
68
- /**
69
- * Type for the redactor function returned by @pinojs/redact
70
- */
71
- export type Redactor = <T>(obj: T) => T;
72
-
73
- /**
74
- * Creates a redactor function based on the provided options.
75
- *
76
- * @param options - Redaction configuration
77
- * @returns A redactor function, or undefined if redaction is disabled
78
- *
79
- * @example
80
- * const redactor = createRedactor(true);
81
- * const safe = redactor({ headers: { authorization: 'Bearer secret' } });
82
- * // safe.headers.authorization === '[REDACTED]'
83
- */
84
- export function createRedactor(
85
- options: TelescopeRedactOptions | undefined,
86
- ): Redactor | undefined {
87
- if (options === undefined || options === false) {
88
- return undefined;
89
- }
90
-
91
- let paths: string[];
92
- let censor: string = '[REDACTED]';
93
-
94
- if (options === true) {
95
- // Use defaults only
96
- paths = DEFAULT_REDACT_PATHS;
97
- } else if (Array.isArray(options)) {
98
- // Merge custom paths with defaults
99
- paths = [...DEFAULT_REDACT_PATHS, ...options];
100
- } else {
101
- // Object configuration
102
- paths = [...DEFAULT_REDACT_PATHS, ...options.paths];
103
- if (options.censor !== undefined) {
104
- censor = options.censor;
105
- }
106
- }
107
-
108
- // Create the redactor with serialize: false to return objects
109
- const redact = pinoRedact({
110
- paths,
111
- censor,
112
- serialize: false,
113
- });
114
-
115
- return redact as Redactor;
116
- }