@beignet/devtools 0.0.2 → 0.0.4

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 (64) hide show
  1. package/CHANGELOG.md +97 -0
  2. package/README.md +117 -71
  3. package/dist/events.d.ts +16 -4
  4. package/dist/events.d.ts.map +1 -1
  5. package/dist/events.js +1 -0
  6. package/dist/events.js.map +1 -1
  7. package/dist/index.d.ts +13 -15
  8. package/dist/index.d.ts.map +1 -1
  9. package/dist/index.js +11 -13
  10. package/dist/index.js.map +1 -1
  11. package/dist/persistence.d.ts +1 -1
  12. package/dist/persistence.d.ts.map +1 -1
  13. package/dist/provider-instrumentation.d.ts +1 -1
  14. package/dist/provider-instrumentation.d.ts.map +1 -1
  15. package/dist/provider.d.ts +5 -5
  16. package/dist/provider.d.ts.map +1 -1
  17. package/dist/provider.js +10 -5
  18. package/dist/provider.js.map +1 -1
  19. package/dist/redaction.d.ts +1 -1
  20. package/dist/redaction.d.ts.map +1 -1
  21. package/dist/redaction.js +1 -0
  22. package/dist/redaction.js.map +1 -1
  23. package/dist/routes.d.ts +2 -2
  24. package/dist/routes.d.ts.map +1 -1
  25. package/dist/routes.js +3 -3
  26. package/dist/routes.js.map +1 -1
  27. package/dist/ui-model.d.ts +38 -0
  28. package/dist/ui-model.d.ts.map +1 -0
  29. package/dist/ui-model.js +1039 -0
  30. package/dist/ui-model.js.map +1 -0
  31. package/dist/ui.d.ts +1 -1
  32. package/dist/ui.d.ts.map +1 -1
  33. package/dist/ui.js +314 -163
  34. package/dist/ui.js.map +1 -1
  35. package/dist/watchers.d.ts +2 -2
  36. package/dist/watchers.d.ts.map +1 -1
  37. package/dist/watchers.js +18 -2
  38. package/dist/watchers.js.map +1 -1
  39. package/package.json +22 -2
  40. package/src/events.ts +32 -2
  41. package/src/index.ts +13 -15
  42. package/src/persistence.ts +1 -1
  43. package/src/provider-instrumentation.ts +1 -1
  44. package/src/provider.ts +12 -7
  45. package/src/redaction.ts +2 -1
  46. package/src/routes.ts +4 -4
  47. package/src/ui-model.ts +1233 -0
  48. package/src/ui.ts +314 -163
  49. package/src/watchers.ts +20 -3
  50. package/dist/audit.d.ts +0 -31
  51. package/dist/audit.d.ts.map +0 -1
  52. package/dist/audit.js +0 -55
  53. package/dist/audit.js.map +0 -1
  54. package/dist/instrumentation.d.ts +0 -114
  55. package/dist/instrumentation.d.ts.map +0 -1
  56. package/dist/instrumentation.js +0 -303
  57. package/dist/instrumentation.js.map +0 -1
  58. package/dist/trace-context.d.ts +0 -80
  59. package/dist/trace-context.d.ts.map +0 -1
  60. package/dist/trace-context.js +0 -92
  61. package/dist/trace-context.js.map +0 -1
  62. package/src/audit.ts +0 -92
  63. package/src/instrumentation.ts +0 -491
  64. package/src/trace-context.ts +0 -166
package/src/watchers.ts CHANGED
@@ -1,4 +1,4 @@
1
- import type { DevtoolsEvent } from "./events";
1
+ import type { DevtoolsEvent } from "./events.js";
2
2
 
3
3
  /**
4
4
  * Built-in devtools watcher names.
@@ -9,11 +9,13 @@ export const BUILT_IN_DEVTOOLS_WATCHER_NAMES = [
9
9
  "useCases",
10
10
  "eventBus",
11
11
  "jobs",
12
+ "outbox",
12
13
  "schedules",
13
14
  "providers",
14
15
  "db",
15
16
  "cache",
16
17
  "storage",
18
+ "uploads",
17
19
  "mail",
18
20
  "notifications",
19
21
  "auth",
@@ -115,10 +117,17 @@ const BUILT_IN_DEVTOOLS_WATCHERS = {
115
117
  eventTypes: ["job"],
116
118
  enabled: true,
117
119
  },
120
+ outbox: {
121
+ name: "outbox",
122
+ label: "Outbox",
123
+ description: "Durable outbox delivery, retries, and dead letters.",
124
+ eventTypes: ["outbox", "custom"],
125
+ enabled: true,
126
+ },
118
127
  schedules: {
119
128
  name: "schedules",
120
129
  label: "Schedules",
121
- description: "Scheduled task execution.",
130
+ description: "Schedule execution.",
122
131
  eventTypes: ["schedule"],
123
132
  enabled: true,
124
133
  },
@@ -151,6 +160,13 @@ const BUILT_IN_DEVTOOLS_WATCHERS = {
151
160
  eventTypes: ["custom"],
152
161
  enabled: true,
153
162
  },
163
+ uploads: {
164
+ name: "uploads",
165
+ label: "Uploads",
166
+ description: "Upload preparation, direct upload signing, and completion.",
167
+ eventTypes: ["custom"],
168
+ enabled: true,
169
+ },
154
170
  mail: {
155
171
  name: "mail",
156
172
  label: "Mail",
@@ -183,7 +199,8 @@ const BUILT_IN_DEVTOOLS_WATCHERS = {
183
199
  rateLimit: {
184
200
  name: "rateLimit",
185
201
  label: "Rate limits",
186
- description: "Rate limit checks from first-party providers.",
202
+ description:
203
+ "Rate limit checks from first-party providers and denial events from the core rate-limit hook.",
187
204
  eventTypes: ["custom"],
188
205
  enabled: true,
189
206
  },
package/dist/audit.d.ts DELETED
@@ -1,31 +0,0 @@
1
- import { type AuditLogEntry, type AuditLogPort } from "@beignet/core/ports";
2
- import type { DevtoolsPort } from "./index";
3
- /**
4
- * Options for wrapping an audit log with devtools emission.
5
- */
6
- export interface DevtoolsAuditLogOptions {
7
- /**
8
- * Durable audit log to write first.
9
- */
10
- audit: AuditLogPort;
11
- /**
12
- * Optional devtools port that receives audit events.
13
- */
14
- devtools?: DevtoolsPort;
15
- /**
16
- * Whether to emit devtools events. Defaults to true.
17
- */
18
- emit?: boolean;
19
- /**
20
- * Optional app-owned redactor applied after Beignet's audit redaction.
21
- */
22
- redact?: (entry: AuditLogEntry) => AuditLogEntry;
23
- }
24
- /**
25
- * Wrap an audit log so durable audit writes can also appear in devtools.
26
- *
27
- * Devtools observer failures are ignored so audit persistence remains the
28
- * source of truth.
29
- */
30
- export declare function createDevtoolsAuditLog(options: DevtoolsAuditLogOptions): AuditLogPort;
31
- //# sourceMappingURL=audit.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"audit.d.ts","sourceRoot":"","sources":["../src/audit.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,KAAK,aAAa,EAElB,KAAK,YAAY,EAGlB,MAAM,qBAAqB,CAAC;AAC7B,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,SAAS,CAAC;AAE5C;;GAEG;AACH,MAAM,WAAW,uBAAuB;IACtC;;OAEG;IACH,KAAK,EAAE,YAAY,CAAC;IACpB;;OAEG;IACH,QAAQ,CAAC,EAAE,YAAY,CAAC;IACxB;;OAEG;IACH,IAAI,CAAC,EAAE,OAAO,CAAC;IACf;;OAEG;IACH,MAAM,CAAC,EAAE,CAAC,KAAK,EAAE,aAAa,KAAK,aAAa,CAAC;CAClD;AAoBD;;;;;GAKG;AACH,wBAAgB,sBAAsB,CACpC,OAAO,EAAE,uBAAuB,GAC/B,YAAY,CAkCd"}
package/dist/audit.js DELETED
@@ -1,55 +0,0 @@
1
- import { normalizeAuditLogEntry, redactAuditLogEntry, } from "@beignet/core/ports";
2
- function prepareEntry(input, redact) {
3
- const redacted = redactAuditLogEntry(normalizeAuditLogEntry(input));
4
- return redact ? redact(redacted) : redacted;
5
- }
6
- function auditSummary(entry) {
7
- const resource = entry.resource?.id
8
- ? `${entry.resource.type}:${entry.resource.id}`
9
- : entry.resource?.type;
10
- const outcome = entry.outcome === "failure" ? "failed" : "succeeded";
11
- return resource
12
- ? `${entry.action} ${outcome} for ${resource}`
13
- : `${entry.action} ${outcome}`;
14
- }
15
- /**
16
- * Wrap an audit log so durable audit writes can also appear in devtools.
17
- *
18
- * Devtools observer failures are ignored so audit persistence remains the
19
- * source of truth.
20
- */
21
- export function createDevtoolsAuditLog(options) {
22
- return {
23
- async record(input) {
24
- const entry = prepareEntry(input, options.redact);
25
- await options.audit.record(entry);
26
- if (options.emit === false || !options.devtools)
27
- return;
28
- try {
29
- options.devtools.record({
30
- type: "custom",
31
- watcher: "audit",
32
- name: entry.action,
33
- label: "Audit",
34
- summary: auditSummary(entry),
35
- requestId: entry.requestId,
36
- traceId: entry.traceId,
37
- details: {
38
- action: entry.action,
39
- actor: entry.actor,
40
- tenant: entry.tenant,
41
- resource: entry.resource,
42
- outcome: entry.outcome,
43
- message: entry.message,
44
- metadata: entry.metadata,
45
- occurredAt: entry.occurredAt.toISOString(),
46
- },
47
- });
48
- }
49
- catch {
50
- // Devtools is an observer; durable audit writes must not depend on it.
51
- }
52
- },
53
- };
54
- }
55
- //# sourceMappingURL=audit.js.map
package/dist/audit.js.map DELETED
@@ -1 +0,0 @@
1
- {"version":3,"file":"audit.js","sourceRoot":"","sources":["../src/audit.ts"],"names":[],"mappings":"AAAA,OAAO,EAIL,sBAAsB,EACtB,mBAAmB,GACpB,MAAM,qBAAqB,CAAC;AAyB7B,SAAS,YAAY,CACnB,KAAyB,EACzB,MAAgD;IAEhD,MAAM,QAAQ,GAAG,mBAAmB,CAAC,sBAAsB,CAAC,KAAK,CAAC,CAAC,CAAC;IACpE,OAAO,MAAM,CAAC,CAAC,CAAC,MAAM,CAAC,QAAQ,CAAC,CAAC,CAAC,CAAC,QAAQ,CAAC;AAC9C,CAAC;AAED,SAAS,YAAY,CAAC,KAAoB;IACxC,MAAM,QAAQ,GAAG,KAAK,CAAC,QAAQ,EAAE,EAAE;QACjC,CAAC,CAAC,GAAG,KAAK,CAAC,QAAQ,CAAC,IAAI,IAAI,KAAK,CAAC,QAAQ,CAAC,EAAE,EAAE;QAC/C,CAAC,CAAC,KAAK,CAAC,QAAQ,EAAE,IAAI,CAAC;IACzB,MAAM,OAAO,GAAG,KAAK,CAAC,OAAO,KAAK,SAAS,CAAC,CAAC,CAAC,QAAQ,CAAC,CAAC,CAAC,WAAW,CAAC;IACrE,OAAO,QAAQ;QACb,CAAC,CAAC,GAAG,KAAK,CAAC,MAAM,IAAI,OAAO,QAAQ,QAAQ,EAAE;QAC9C,CAAC,CAAC,GAAG,KAAK,CAAC,MAAM,IAAI,OAAO,EAAE,CAAC;AACnC,CAAC;AAED;;;;;GAKG;AACH,MAAM,UAAU,sBAAsB,CACpC,OAAgC;IAEhC,OAAO;QACL,KAAK,CAAC,MAAM,CAAC,KAAK;YAChB,MAAM,KAAK,GAAG,YAAY,CAAC,KAAK,EAAE,OAAO,CAAC,MAAM,CAAC,CAAC;YAElD,MAAM,OAAO,CAAC,KAAK,CAAC,MAAM,CAAC,KAAK,CAAC,CAAC;YAElC,IAAI,OAAO,CAAC,IAAI,KAAK,KAAK,IAAI,CAAC,OAAO,CAAC,QAAQ;gBAAE,OAAO;YAExD,IAAI,CAAC;gBACH,OAAO,CAAC,QAAQ,CAAC,MAAM,CAAC;oBACtB,IAAI,EAAE,QAAQ;oBACd,OAAO,EAAE,OAAO;oBAChB,IAAI,EAAE,KAAK,CAAC,MAAM;oBAClB,KAAK,EAAE,OAAO;oBACd,OAAO,EAAE,YAAY,CAAC,KAAK,CAAC;oBAC5B,SAAS,EAAE,KAAK,CAAC,SAAS;oBAC1B,OAAO,EAAE,KAAK,CAAC,OAAO;oBACtB,OAAO,EAAE;wBACP,MAAM,EAAE,KAAK,CAAC,MAAM;wBACpB,KAAK,EAAE,KAAK,CAAC,KAAK;wBAClB,MAAM,EAAE,KAAK,CAAC,MAAM;wBACpB,QAAQ,EAAE,KAAK,CAAC,QAAQ;wBACxB,OAAO,EAAE,KAAK,CAAC,OAAO;wBACtB,OAAO,EAAE,KAAK,CAAC,OAAO;wBACtB,QAAQ,EAAE,KAAK,CAAC,QAAQ;wBACxB,UAAU,EAAE,KAAK,CAAC,UAAU,CAAC,WAAW,EAAE;qBAC3C;iBACF,CAAC,CAAC;YACL,CAAC;YAAC,MAAM,CAAC;gBACP,uEAAuE;YACzE,CAAC;QACH,CAAC;KACF,CAAC;AACJ,CAAC"}
@@ -1,114 +0,0 @@
1
- import type { AnyPorts } from "@beignet/core/ports";
2
- import type { HttpContractConfig, HttpRequestLike, HttpResponseLike, ServerHook } from "@beignet/core/server";
3
- import type { DevtoolsRedactor } from "./events";
4
- import type { DevtoolsPort } from "./index";
5
- import { type DevtoolsTraceContextInput } from "./trace-context";
6
- type PortsWithDevtools = AnyPorts & {
7
- devtools?: DevtoolsPort;
8
- };
9
- /**
10
- * Options for server hooks that record request/error events to devtools.
11
- */
12
- export interface DevtoolsHooksOptions<Ctx> {
13
- /**
14
- * Devtools route prefix. Requests under this path are ignored to avoid
15
- * filling the timeline with its own polling traffic.
16
- *
17
- * @default "/api/devtools"
18
- */
19
- basePath?: string;
20
- /**
21
- * Resolve the request ID used for event correlation.
22
- */
23
- getRequestId?: (args: {
24
- req: HttpRequestLike;
25
- ctx?: Ctx;
26
- response?: HttpResponseLike;
27
- }) => string | undefined;
28
- /**
29
- * Response header used to expose the resolved request ID.
30
- *
31
- * Pass `false` to avoid writing a header.
32
- *
33
- * @default "x-request-id"
34
- */
35
- requestIdHeader?: string | false;
36
- /**
37
- * W3C trace context header used to correlate devtools events with distributed
38
- * traces.
39
- *
40
- * Pass `false` to avoid writing a header.
41
- *
42
- * @default "traceparent"
43
- */
44
- traceContextHeader?: string | false;
45
- /**
46
- * Resolve a trace context from request/context/response data.
47
- */
48
- getTraceContext?: (args: {
49
- req: HttpRequestLike;
50
- ctx?: Ctx;
51
- response?: HttpResponseLike;
52
- }) => DevtoolsTraceContextInput | string | undefined;
53
- /**
54
- * Apply a custom redactor to events produced by these hooks. The default
55
- * devtools redactor still runs when events are stored.
56
- */
57
- redact?: DevtoolsRedactor;
58
- /**
59
- * Decide whether to capture a completed request event.
60
- */
61
- shouldCapture?: (args: {
62
- req: HttpRequestLike;
63
- ctx?: Ctx;
64
- contract: HttpContractConfig;
65
- response: HttpResponseLike;
66
- error?: unknown;
67
- }) => boolean;
68
- }
69
- /**
70
- * Use-case run event shape consumed by the devtools observer.
71
- */
72
- export interface DevtoolsUseCaseRunEvent<Ctx> {
73
- name: string;
74
- kind: "command" | "query";
75
- phase: "start" | "end" | "error";
76
- durationMs?: number;
77
- error?: unknown;
78
- ctx: Ctx;
79
- }
80
- /**
81
- * Options for `createDevtoolsUseCaseObserver(...)`.
82
- */
83
- export interface DevtoolsUseCaseObserverOptions<Ctx> {
84
- /**
85
- * Resolve a devtools port from use-case context.
86
- */
87
- getDevtools?: (ctx: Ctx) => DevtoolsPort | undefined;
88
- /**
89
- * Resolve the request ID used for event correlation.
90
- */
91
- getRequestId?: (ctx: Ctx) => string | undefined;
92
- /**
93
- * Whether use-case error phases should also emit `error` events.
94
- */
95
- logErrorEvents?: boolean;
96
- /**
97
- * Optional redactor applied before events are recorded.
98
- */
99
- redact?: DevtoolsRedactor;
100
- }
101
- /**
102
- * Create server hooks that record Beignet request and error activity.
103
- *
104
- * Devtools routes under `basePath` are ignored so polling and SSE traffic do not
105
- * fill the event buffer. Request IDs and trace context are also written to
106
- * response headers unless disabled.
107
- */
108
- export declare function createDevtoolsHooks<Ctx, Ports extends PortsWithDevtools = PortsWithDevtools>(options?: DevtoolsHooksOptions<Ctx>): ServerHook<Ctx, Ports>;
109
- /**
110
- * Create a use-case observer compatible with `createUseCase({ onRun })`.
111
- */
112
- export declare function createDevtoolsUseCaseObserver<Ctx>(options?: DevtoolsUseCaseObserverOptions<Ctx>): (event: DevtoolsUseCaseRunEvent<Ctx>) => void;
113
- export {};
114
- //# sourceMappingURL=instrumentation.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"instrumentation.d.ts","sourceRoot":"","sources":["../src/instrumentation.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,qBAAqB,CAAC;AACpD,OAAO,KAAK,EACV,kBAAkB,EAClB,eAAe,EACf,gBAAgB,EAChB,UAAU,EACX,MAAM,sBAAsB,CAAC;AAC9B,OAAO,KAAK,EAAsB,gBAAgB,EAAE,MAAM,UAAU,CAAC;AACrE,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,SAAS,CAAC;AAE5C,OAAO,EAIL,KAAK,yBAAyB,EAE/B,MAAM,iBAAiB,CAAC;AAGzB,KAAK,iBAAiB,GAAG,QAAQ,GAAG;IAClC,QAAQ,CAAC,EAAE,YAAY,CAAC;CACzB,CAAC;AAaF;;GAEG;AACH,MAAM,WAAW,oBAAoB,CAAC,GAAG;IACvC;;;;;OAKG;IACH,QAAQ,CAAC,EAAE,MAAM,CAAC;IAEl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E,GAAG,KAAK,YAAY,GAAG,SAAS,CAAC;IACrD;;OAEG;IACH,YAAY,CAAC,EAAE,CAAC,GAAG,EAAE,GAAG,KAAK,MAAM,GAAG,SAAS,CAAC;IAChD;;OAEG;IACH,cAAc,CAAC,EAAE,OAAO,CAAC;IACzB;;OAEG;IACH,MAAM,CAAC,EAAE,gBAAgB,CAAC;CAC3B;AA0ED;;;;;;GAMG;AACH,wBAAgB,mBAAmB,CACjC,GAAG,EACH,KAAK,SAAS,iBAAiB,GAAG,iBAAiB,EACnD,OAAO,GAAE,oBAAoB,CAAC,GAAG,CAAM,GAAG,UAAU,CAAC,GAAG,EAAE,KAAK,CAAC,CAmLjE;AAED;;GAEG;AACH,wBAAgB,6BAA6B,CAAC,GAAG,EAC/C,OAAO,GAAE,8BAA8B,CAAC,GAAG,CAAM,GAChD,CAAC,KAAK,EAAE,uBAAuB,CAAC,GAAG,CAAC,KAAK,IAAI,CAuF/C"}
@@ -1,303 +0,0 @@
1
- import { createDevtoolsEvent } from "./provider";
2
- import { createChildDevtoolsTraceContext, createDevtoolsTraceContext, parseTraceparent, } from "./trace-context";
3
- function getContextRequestId(ctx) {
4
- if (!ctx || typeof ctx !== "object")
5
- return undefined;
6
- const requestId = ctx.requestId;
7
- return typeof requestId === "string" ? requestId : undefined;
8
- }
9
- function getContextDevtools(ctx) {
10
- if (!ctx || typeof ctx !== "object")
11
- return undefined;
12
- const ports = ctx.ports;
13
- return ports?.devtools;
14
- }
15
- function getContextTraceContext(ctx) {
16
- if (!ctx || typeof ctx !== "object")
17
- return undefined;
18
- const context = ctx;
19
- if (!context.traceId &&
20
- !context.spanId &&
21
- !context.parentSpanId &&
22
- !context.traceparent) {
23
- return undefined;
24
- }
25
- return {
26
- traceId: context.traceId,
27
- spanId: context.spanId,
28
- parentSpanId: context.parentSpanId,
29
- traceparent: context.traceparent,
30
- };
31
- }
32
- function getErrorMessage(error) {
33
- if (error instanceof Error)
34
- return error.message;
35
- if (typeof error === "string")
36
- return error;
37
- return "Unknown error";
38
- }
39
- function getErrorStack(error) {
40
- return error instanceof Error ? error.stack : undefined;
41
- }
42
- function createRequestId() {
43
- if (typeof crypto !== "undefined" && "randomUUID" in crypto) {
44
- return crypto.randomUUID();
45
- }
46
- return `${Date.now()}-${Math.random().toString(16).slice(2)}`;
47
- }
48
- function getPathname(req) {
49
- try {
50
- return new URL(req.url).pathname;
51
- }
52
- catch {
53
- return req.url;
54
- }
55
- }
56
- function isDevtoolsPath(pathname, basePath) {
57
- const normalizedBase = basePath.replace(/\/+$/, "");
58
- return (pathname === normalizedBase || pathname.startsWith(`${normalizedBase}/`));
59
- }
60
- function isWatcherEnabled(devtools, name) {
61
- return devtools.isWatcherEnabled(name);
62
- }
63
- /**
64
- * Create server hooks that record Beignet request and error activity.
65
- *
66
- * Devtools routes under `basePath` are ignored so polling and SSE traffic do not
67
- * fill the event buffer. Request IDs and trace context are also written to
68
- * response headers unless disabled.
69
- */
70
- export function createDevtoolsHooks(options = {}) {
71
- let devtools;
72
- const basePath = options.basePath ?? "/api/devtools";
73
- const requestIdHeader = options.requestIdHeader ?? "x-request-id";
74
- const traceContextHeader = options.traceContextHeader ?? "traceparent";
75
- const generatedRequestIds = new WeakMap();
76
- const traceContexts = new WeakMap();
77
- const resolveRequestId = (args) => {
78
- const headerRequestId = requestIdHeader === false
79
- ? undefined
80
- : args.req.headers.get(requestIdHeader);
81
- const existing = options.getRequestId?.(args) ??
82
- getContextRequestId(args.ctx) ??
83
- headerRequestId ??
84
- generatedRequestIds.get(args.req);
85
- if (existing)
86
- return existing;
87
- const requestId = createRequestId();
88
- generatedRequestIds.set(args.req, requestId);
89
- return requestId;
90
- };
91
- const resolveTraceContext = (args) => {
92
- const configured = options.getTraceContext?.(args);
93
- const configuredContext = typeof configured === "string" ? { traceparent: configured } : configured;
94
- const contextTrace = getContextTraceContext(args.ctx);
95
- const headerTraceparent = traceContextHeader === false
96
- ? undefined
97
- : args.req.headers.get(traceContextHeader);
98
- const existing = configuredContext ?? contextTrace;
99
- const existingTraceparent = existing?.traceparent ?? parseTraceparent(headerTraceparent)?.traceparent;
100
- if (existing) {
101
- const traceContext = createDevtoolsTraceContext({
102
- ...existing,
103
- traceparent: existingTraceparent,
104
- });
105
- traceContexts.set(args.req, traceContext);
106
- return traceContext;
107
- }
108
- const cached = traceContexts.get(args.req);
109
- if (cached)
110
- return cached;
111
- const traceContext = createDevtoolsTraceContext({
112
- traceparent: existingTraceparent,
113
- });
114
- traceContexts.set(args.req, traceContext);
115
- return traceContext;
116
- };
117
- const record = (event) => {
118
- if (!devtools)
119
- return;
120
- const normalized = createDevtoolsEvent(event);
121
- try {
122
- devtools.record(options.redact ? options.redact(normalized) : normalized);
123
- }
124
- catch (error) {
125
- devtools.record({
126
- type: "error",
127
- message: "Devtools hook redactor failed",
128
- details: {
129
- message: error instanceof Error ? error.message : String(error),
130
- },
131
- });
132
- }
133
- };
134
- return {
135
- name: "devtools",
136
- onRequest: ({ ports }) => {
137
- devtools = ports.devtools;
138
- return undefined;
139
- },
140
- beforeHandle: ({ req, ctx }) => {
141
- if (!ctx || typeof ctx !== "object" || Array.isArray(ctx)) {
142
- return undefined;
143
- }
144
- const traceContext = resolveTraceContext({ req, ctx });
145
- return {
146
- ctx: {
147
- ...ctx,
148
- traceId: traceContext.traceId,
149
- spanId: traceContext.spanId,
150
- parentSpanId: traceContext.parentSpanId,
151
- traceparent: traceContext.traceparent,
152
- },
153
- };
154
- },
155
- beforeSend: async ({ req, ctx, response }) => {
156
- if (requestIdHeader === false && traceContextHeader === false) {
157
- return undefined;
158
- }
159
- const requestId = resolveRequestId({ req, ctx, response });
160
- const traceContext = resolveTraceContext({ req, ctx, response });
161
- const headers = {
162
- ...response.headers,
163
- ...(requestIdHeader === false ? {} : { [requestIdHeader]: requestId }),
164
- ...(traceContextHeader === false
165
- ? {}
166
- : { [traceContextHeader]: traceContext.traceparent }),
167
- };
168
- return {
169
- ...response,
170
- headers,
171
- };
172
- },
173
- afterSend: async ({ req, ctx, contract, response, error, durationMs }) => {
174
- if (!devtools)
175
- return;
176
- const path = getPathname(req);
177
- if (isDevtoolsPath(path, basePath))
178
- return;
179
- const shouldCaptureRequest = isWatcherEnabled(devtools, "requests");
180
- const shouldCaptureError = Boolean(error) && isWatcherEnabled(devtools, "errors");
181
- if (!shouldCaptureRequest && !shouldCaptureError)
182
- return;
183
- if (options.shouldCapture &&
184
- !options.shouldCapture({ req, ctx, contract, response, error })) {
185
- return;
186
- }
187
- const requestId = resolveRequestId({ req, ctx, response });
188
- const traceContext = resolveTraceContext({ req, ctx, response });
189
- if (shouldCaptureRequest) {
190
- record({
191
- type: "request",
192
- requestId,
193
- traceId: traceContext.traceId,
194
- spanId: traceContext.spanId,
195
- parentSpanId: traceContext.parentSpanId,
196
- traceparent: traceContext.traceparent,
197
- method: req.method,
198
- path,
199
- contractName: contract.name,
200
- status: response.status,
201
- durationMs,
202
- details: {
203
- headers: Object.fromEntries(req.headers.entries()),
204
- },
205
- });
206
- }
207
- if (error && shouldCaptureError) {
208
- record({
209
- type: "error",
210
- requestId,
211
- traceId: traceContext.traceId,
212
- spanId: traceContext.spanId,
213
- parentSpanId: traceContext.parentSpanId,
214
- traceparent: traceContext.traceparent,
215
- message: getErrorMessage(error),
216
- stack: getErrorStack(error),
217
- contractName: contract.name,
218
- });
219
- }
220
- },
221
- };
222
- }
223
- /**
224
- * Create a use-case observer compatible with `createUseCase({ onRun })`.
225
- */
226
- export function createDevtoolsUseCaseObserver(options = {}) {
227
- const logErrorEvents = options.logErrorEvents ?? true;
228
- const activeTraceContexts = new Map();
229
- return (event) => {
230
- const devtools = options.getDevtools?.(event.ctx) ?? getContextDevtools(event.ctx);
231
- if (!devtools)
232
- return;
233
- const requestId = options.getRequestId?.(event.ctx) ?? getContextRequestId(event.ctx);
234
- const errorMessage = event.phase === "error" ? getErrorMessage(event.error) : undefined;
235
- const shouldCaptureUseCase = isWatcherEnabled(devtools, "useCases");
236
- const shouldCaptureError = event.phase === "error" &&
237
- logErrorEvents &&
238
- isWatcherEnabled(devtools, "errors");
239
- if (!shouldCaptureUseCase && !shouldCaptureError)
240
- return;
241
- const parentTraceContext = getContextTraceContext(event.ctx);
242
- const useCaseKey = [
243
- requestId ?? "no-request",
244
- parentTraceContext?.traceId ?? "no-trace",
245
- event.kind,
246
- event.name,
247
- ].join(":");
248
- const traceContext = event.phase === "start"
249
- ? createChildDevtoolsTraceContext(parentTraceContext ?? {})
250
- : (activeTraceContexts.get(useCaseKey) ??
251
- createChildDevtoolsTraceContext(parentTraceContext ?? {}));
252
- if (event.phase === "start") {
253
- activeTraceContexts.set(useCaseKey, traceContext);
254
- }
255
- else {
256
- activeTraceContexts.delete(useCaseKey);
257
- }
258
- const record = (input) => {
259
- const normalized = createDevtoolsEvent(input);
260
- try {
261
- devtools.record(options.redact ? options.redact(normalized) : normalized);
262
- }
263
- catch (error) {
264
- devtools.record({
265
- type: "error",
266
- message: "Devtools use case redactor failed",
267
- details: {
268
- message: error instanceof Error ? error.message : String(error),
269
- },
270
- });
271
- }
272
- };
273
- if (shouldCaptureUseCase) {
274
- record({
275
- type: "usecase",
276
- requestId,
277
- traceId: traceContext.traceId,
278
- spanId: traceContext.spanId,
279
- parentSpanId: traceContext.parentSpanId,
280
- traceparent: traceContext.traceparent,
281
- name: event.name,
282
- kind: event.kind,
283
- phase: event.phase,
284
- durationMs: event.durationMs,
285
- error: errorMessage,
286
- });
287
- }
288
- if (shouldCaptureError) {
289
- record({
290
- type: "error",
291
- requestId,
292
- traceId: traceContext.traceId,
293
- spanId: traceContext.spanId,
294
- parentSpanId: traceContext.parentSpanId,
295
- traceparent: traceContext.traceparent,
296
- message: errorMessage ?? "Use case failed",
297
- stack: getErrorStack(event.error),
298
- useCaseName: event.name,
299
- });
300
- }
301
- };
302
- }
303
- //# sourceMappingURL=instrumentation.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"instrumentation.js","sourceRoot":"","sources":["../src/instrumentation.ts"],"names":[],"mappings":"AASA,OAAO,EAAE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ACT,OAAO,EAAE,YAAY,CAAC,OAAO;gBAC7B,MAAM,EAAE,YAAY,CAAC,MAAM;gBAC3B,YAAY,EAAE,YAAY,CAAC,YAAY;gBACvC,WAAW,EAAE,YAAY,CAAC,WAAW;gBACrC,OAAO,EAAE,YAAY,IAAI,iBAAiB;gBAC1C,KAAK,EAAE,aAAa,CAAC,KAAK,CAAC,KAAK,CAAC;gBACjC,WAAW,EAAE,KAAK,CAAC,IAAI;aACxB,CAAC,CAAC;QACL,CAAC;IACH,CAAC,CAAC;AACJ,CAAC"}
@@ -1,80 +0,0 @@
1
- /**
2
- * Devtools trace context used to correlate related events.
3
- */
4
- export interface DevtoolsTraceContext {
5
- /**
6
- * W3C trace ID.
7
- */
8
- traceId: string;
9
- /**
10
- * Current span ID.
11
- */
12
- spanId: string;
13
- /**
14
- * Parent span ID when available.
15
- */
16
- parentSpanId?: string;
17
- /**
18
- * W3C traceparent header value.
19
- */
20
- traceparent: string;
21
- }
22
- /**
23
- * Parsed W3C traceparent header.
24
- */
25
- export interface ParsedTraceparent {
26
- /**
27
- * W3C trace ID.
28
- */
29
- traceId: string;
30
- /**
31
- * Span ID from the traceparent header.
32
- */
33
- spanId: string;
34
- /**
35
- * Trace flags from the traceparent header.
36
- */
37
- traceFlags: string;
38
- /**
39
- * Normalized traceparent header value.
40
- */
41
- traceparent: string;
42
- }
43
- /**
44
- * Input accepted when creating devtools trace context.
45
- */
46
- export interface DevtoolsTraceContextInput {
47
- traceId?: string;
48
- spanId?: string;
49
- parentSpanId?: string;
50
- traceparent?: string;
51
- }
52
- /**
53
- * Create a non-zero W3C trace ID.
54
- */
55
- export declare function createTraceId(): string;
56
- /**
57
- * Create a non-zero W3C span ID.
58
- */
59
- export declare function createSpanId(): string;
60
- /**
61
- * Create a W3C traceparent header value.
62
- */
63
- export declare function createTraceparent(args: {
64
- traceId: string;
65
- spanId: string;
66
- traceFlags?: string;
67
- }): string;
68
- /**
69
- * Parse and validate a W3C traceparent header value.
70
- */
71
- export declare function parseTraceparent(value: string | null | undefined): ParsedTraceparent | undefined;
72
- /**
73
- * Create devtools trace context from explicit IDs or an existing traceparent.
74
- */
75
- export declare function createDevtoolsTraceContext(input?: DevtoolsTraceContextInput): DevtoolsTraceContext;
76
- /**
77
- * Create child trace context from a parent context.
78
- */
79
- export declare function createChildDevtoolsTraceContext(parent: DevtoolsTraceContextInput): DevtoolsTraceContext;
80
- //# sourceMappingURL=trace-context.d.ts.map