@beignet/devtools 0.0.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.
- package/CHANGELOG.md +5 -0
- package/README.md +464 -0
- package/dist/access.d.ts +21 -0
- package/dist/access.d.ts.map +1 -0
- package/dist/access.js +20 -0
- package/dist/access.js.map +1 -0
- package/dist/audit.d.ts +10 -0
- package/dist/audit.d.ts.map +1 -0
- package/dist/audit.js +49 -0
- package/dist/audit.js.map +1 -0
- package/dist/events.d.ts +143 -0
- package/dist/events.d.ts.map +1 -0
- package/dist/events.js +20 -0
- package/dist/events.js.map +1 -0
- package/dist/index.d.ts +114 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +44 -0
- package/dist/index.js.map +1 -0
- package/dist/instrumentation.d.ts +74 -0
- package/dist/instrumentation.d.ts.map +1 -0
- package/dist/instrumentation.js +293 -0
- package/dist/instrumentation.js.map +1 -0
- package/dist/persistence.d.ts +30 -0
- package/dist/persistence.d.ts.map +1 -0
- package/dist/persistence.js +100 -0
- package/dist/persistence.js.map +1 -0
- package/dist/provider-instrumentation.d.ts +9 -0
- package/dist/provider-instrumentation.d.ts.map +1 -0
- package/dist/provider-instrumentation.js +25 -0
- package/dist/provider-instrumentation.js.map +1 -0
- package/dist/provider.d.ts +79 -0
- package/dist/provider.d.ts.map +1 -0
- package/dist/provider.js +293 -0
- package/dist/provider.js.map +1 -0
- package/dist/redaction.d.ts +5 -0
- package/dist/redaction.d.ts.map +1 -0
- package/dist/redaction.js +20 -0
- package/dist/redaction.js.map +1 -0
- package/dist/routes.d.ts +113 -0
- package/dist/routes.d.ts.map +1 -0
- package/dist/routes.js +247 -0
- package/dist/routes.js.map +1 -0
- package/dist/trace-context.d.ts +29 -0
- package/dist/trace-context.d.ts.map +1 -0
- package/dist/trace-context.js +74 -0
- package/dist/trace-context.js.map +1 -0
- package/dist/ui.d.ts +14 -0
- package/dist/ui.d.ts.map +1 -0
- package/dist/ui.js +795 -0
- package/dist/ui.js.map +1 -0
- package/dist/watchers.d.ts +22 -0
- package/dist/watchers.d.ts.map +1 -0
- package/dist/watchers.js +171 -0
- package/dist/watchers.js.map +1 -0
- package/package.json +66 -0
- package/src/access.ts +52 -0
- package/src/audit.ts +71 -0
- package/src/events.ts +193 -0
- package/src/index.ts +136 -0
- package/src/instrumentation.ts +451 -0
- package/src/persistence.ts +163 -0
- package/src/provider-instrumentation.ts +50 -0
- package/src/provider.ts +375 -0
- package/src/redaction.ts +26 -0
- package/src/routes.ts +317 -0
- package/src/trace-context.ts +115 -0
- package/src/ui.ts +807 -0
- package/src/watchers.ts +235 -0
package/dist/events.d.ts
ADDED
|
@@ -0,0 +1,143 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Event types for Beignet devtools
|
|
3
|
+
*
|
|
4
|
+
* These events represent activity within the Beignet server and can be
|
|
5
|
+
* logged during development to aid in debugging and observability.
|
|
6
|
+
*/
|
|
7
|
+
/**
|
|
8
|
+
* Base interface for all devtools events.
|
|
9
|
+
* All events share these common fields for correlation and debugging.
|
|
10
|
+
*/
|
|
11
|
+
export interface BaseDevtoolsEvent {
|
|
12
|
+
/**
|
|
13
|
+
* Unique identifier for this event (UUID or timestamp-based).
|
|
14
|
+
*/
|
|
15
|
+
id: string;
|
|
16
|
+
/**
|
|
17
|
+
* ISO timestamp when the event occurred.
|
|
18
|
+
*/
|
|
19
|
+
timestamp: string;
|
|
20
|
+
/**
|
|
21
|
+
* Optional correlation ID to link events from the same request/operation.
|
|
22
|
+
*/
|
|
23
|
+
requestId?: string;
|
|
24
|
+
/**
|
|
25
|
+
* W3C trace ID for cross-service correlation.
|
|
26
|
+
*/
|
|
27
|
+
traceId?: string;
|
|
28
|
+
/**
|
|
29
|
+
* Span ID for the operation represented by this event.
|
|
30
|
+
*/
|
|
31
|
+
spanId?: string;
|
|
32
|
+
/**
|
|
33
|
+
* Parent span ID when this event belongs to a nested operation.
|
|
34
|
+
*/
|
|
35
|
+
parentSpanId?: string;
|
|
36
|
+
/**
|
|
37
|
+
* W3C traceparent header value associated with this event.
|
|
38
|
+
*/
|
|
39
|
+
traceparent?: string;
|
|
40
|
+
/**
|
|
41
|
+
* Optional watcher name that owns this event. Built-in events can infer their
|
|
42
|
+
* watcher from `type`; custom integrations can set this to use their own
|
|
43
|
+
* watcher configuration.
|
|
44
|
+
*/
|
|
45
|
+
watcher?: string;
|
|
46
|
+
/**
|
|
47
|
+
* Optional structured detail payload. Devtools applies default redaction to
|
|
48
|
+
* this field before events are stored.
|
|
49
|
+
*/
|
|
50
|
+
details?: unknown;
|
|
51
|
+
}
|
|
52
|
+
/**
|
|
53
|
+
* Logged when the server handles a request mapped from a contract.
|
|
54
|
+
*/
|
|
55
|
+
export interface RequestEvent extends BaseDevtoolsEvent {
|
|
56
|
+
type: "request";
|
|
57
|
+
method: string;
|
|
58
|
+
path: string;
|
|
59
|
+
contractName?: string;
|
|
60
|
+
status?: number;
|
|
61
|
+
durationMs?: number;
|
|
62
|
+
summary?: string;
|
|
63
|
+
}
|
|
64
|
+
/**
|
|
65
|
+
* Logged when an error occurs (unhandled or explicit).
|
|
66
|
+
*/
|
|
67
|
+
export interface ErrorEvent extends BaseDevtoolsEvent {
|
|
68
|
+
type: "error";
|
|
69
|
+
message: string;
|
|
70
|
+
stack?: string;
|
|
71
|
+
contractName?: string;
|
|
72
|
+
useCaseName?: string;
|
|
73
|
+
}
|
|
74
|
+
/**
|
|
75
|
+
* Logged when a use case runs.
|
|
76
|
+
*/
|
|
77
|
+
export interface UseCaseEvent extends BaseDevtoolsEvent {
|
|
78
|
+
type: "usecase";
|
|
79
|
+
name: string;
|
|
80
|
+
kind?: "command" | "query";
|
|
81
|
+
phase: "start" | "end" | "error";
|
|
82
|
+
durationMs?: number;
|
|
83
|
+
error?: string;
|
|
84
|
+
}
|
|
85
|
+
/**
|
|
86
|
+
* Logged when the event bus publishes an event.
|
|
87
|
+
*/
|
|
88
|
+
export interface EventBusEvent extends BaseDevtoolsEvent {
|
|
89
|
+
type: "eventBus";
|
|
90
|
+
eventName: string;
|
|
91
|
+
}
|
|
92
|
+
/**
|
|
93
|
+
* Logged when a job is scheduled / starts / completes / fails.
|
|
94
|
+
* Jobs may be backed by Inngest or other providers.
|
|
95
|
+
*/
|
|
96
|
+
export interface JobEvent extends BaseDevtoolsEvent {
|
|
97
|
+
type: "job";
|
|
98
|
+
jobName: string;
|
|
99
|
+
status: "scheduled" | "started" | "completed" | "failed";
|
|
100
|
+
}
|
|
101
|
+
/**
|
|
102
|
+
* Logged when a scheduled task starts, completes, or fails.
|
|
103
|
+
*/
|
|
104
|
+
export interface ScheduleEvent extends BaseDevtoolsEvent {
|
|
105
|
+
type: "schedule";
|
|
106
|
+
scheduleName: string;
|
|
107
|
+
status: "started" | "completed" | "failed";
|
|
108
|
+
cron?: string;
|
|
109
|
+
timezone?: string;
|
|
110
|
+
}
|
|
111
|
+
/**
|
|
112
|
+
* Logged when a provider is set up, started, or stopped.
|
|
113
|
+
*/
|
|
114
|
+
export interface ProviderEvent extends BaseDevtoolsEvent {
|
|
115
|
+
type: "provider";
|
|
116
|
+
providerName: string;
|
|
117
|
+
action: "setup" | "start" | "stop";
|
|
118
|
+
}
|
|
119
|
+
/**
|
|
120
|
+
* Logged by application or integration code for app-specific diagnostics.
|
|
121
|
+
*/
|
|
122
|
+
export interface CustomDevtoolsEvent extends BaseDevtoolsEvent {
|
|
123
|
+
type: "custom";
|
|
124
|
+
name: string;
|
|
125
|
+
label?: string;
|
|
126
|
+
summary?: string;
|
|
127
|
+
}
|
|
128
|
+
/**
|
|
129
|
+
* Union type of all devtools events.
|
|
130
|
+
*/
|
|
131
|
+
export type DevtoolsEvent = RequestEvent | ErrorEvent | UseCaseEvent | EventBusEvent | JobEvent | ScheduleEvent | ProviderEvent | CustomDevtoolsEvent;
|
|
132
|
+
export type DevtoolsEventInput = DevtoolsEvent extends infer Event ? Event extends DevtoolsEvent ? Omit<Event, "id" | "timestamp"> & Partial<Pick<Event, "id" | "timestamp">> : never : never;
|
|
133
|
+
export type DevtoolsRedactor = (event: DevtoolsEvent) => DevtoolsEvent;
|
|
134
|
+
export type DevtoolsSubscriptionEvent = {
|
|
135
|
+
type: "record";
|
|
136
|
+
event: DevtoolsEvent;
|
|
137
|
+
} | {
|
|
138
|
+
type: "clear";
|
|
139
|
+
};
|
|
140
|
+
export type DevtoolsListener = (event: DevtoolsSubscriptionEvent) => void;
|
|
141
|
+
export declare const DEVTOOLS_EVENT_TYPES: readonly ["request", "error", "usecase", "eventBus", "job", "schedule", "provider", "custom"];
|
|
142
|
+
export declare function isDevtoolsEventType(value: string): value is DevtoolsEvent["type"];
|
|
143
|
+
//# sourceMappingURL=events.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"events.d.ts","sourceRoot":"","sources":["../src/events.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAEH;;;GAGG;AACH,MAAM,WAAW,iBAAiB;IAChC;;OAEG;IACH,EAAE,EAAE,MAAM,CAAC;IAEX;;OAEG;IACH,SAAS,EAAE,MAAM,CAAC;IAElB;;OAEG;IACH,SAAS,CAAC,EAAE,MAAM,CAAC;IAEnB;;OAEG;IACH,OAAO,CAAC,EAAE,MAAM,CAAC;IAEjB;;OAEG;IACH,MAAM,CAAC,EAAE,MAAM,CAAC;IAEhB;;OAEG;IACH,YAAY,CAAC,EAAE,MAAM,CAAC;IAEtB;;OAEG;IACH,WAAW,CAAC,EAAE,MAAM,CAAC;IAErB;;;;OAIG;IACH,OAAO,CAAC,EAAE,MAAM,CAAC;IAEjB;;;OAGG;IACH,OAAO,CAAC,EAAE,OAAO,CAAC;CACnB;AAED;;GAEG;AACH,MAAM,WAAW,YAAa,SAAQ,iBAAiB;IACrD,IAAI,EAAE,SAAS,CAAC;IAChB,MAAM,EAAE,MAAM,CAAC;IACf,IAAI,EAAE,MAAM,CAAC;IACb,YAAY,CAAC,EAAE,MAAM,CAAC;IACtB,MAAM,CAAC,EAAE,MAAM,CAAC;IA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AAE,MAAM,CAAC;IACrB,MAAM,EAAE,OAAO,GAAG,OAAO,GAAG,MAAM,CAAC;CACpC;AAED;;GAEG;AACH,MAAM,WAAW,mBAAoB,SAAQ,iBAAiB;IAC5D,IAAI,EAAE,QAAQ,CAAC;IACf,IAAI,EAAE,MAAM,CAAC;IACb,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,OAAO,CAAC,EAAE,MAAM,CAAC;CAClB;AAED;;GAEG;AACH,MAAM,MAAM,aAAa,GACrB,YAAY,GACZ,UAAU,GACV,YAAY,GACZ,aAAa,GACb,QAAQ,GACR,aAAa,GACb,aAAa,GACb,mBAAmB,CAAC;AAExB,MAAM,MAAM,kBAAkB,GAAG,aAAa,SAAS,MAAM,KAAK,GAC9D,KAAK,SAAS,aAAa,GACzB,IAAI,CAAC,KAAK,EAAE,IAAI,GAAG,WAAW,CAAC,GAAG,OAAO,CAAC,IAAI,CAAC,KAAK,EAAE,IAAI,GAAG,WAAW,CAAC,CAAC,GAC1E,KAAK,GACP,KAAK,CAAC;AAEV,MAAM,MAAM,gBAAgB,GAAG,CAAC,KAAK,EAAE,aAAa,KAAK,aAAa,CAAC;AAEvE,MAAM,MAAM,yBAAyB,GACjC;IACE,IAAI,EAAE,QAAQ,CAAC;IACf,KAAK,EAAE,aAAa,CAAC;CACtB,GACD;IACE,IAAI,EAAE,OAAO,CAAC;CACf,CAAC;AAEN,MAAM,MAAM,gBAAgB,GAAG,CAAC,KAAK,EAAE,yBAAyB,KAAK,IAAI,CAAC;AAE1E,eAAO,MAAM,oBAAoB,+FASoB,CAAC;AAEtD,wBAAgB,mBAAmB,CACjC,KAAK,EAAE,MAAM,GACZ,KAAK,IAAI,aAAa,CAAC,MAAM,CAAC,CAEhC"}
|
package/dist/events.js
ADDED
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Event types for Beignet devtools
|
|
3
|
+
*
|
|
4
|
+
* These events represent activity within the Beignet server and can be
|
|
5
|
+
* logged during development to aid in debugging and observability.
|
|
6
|
+
*/
|
|
7
|
+
export const DEVTOOLS_EVENT_TYPES = [
|
|
8
|
+
"request",
|
|
9
|
+
"error",
|
|
10
|
+
"usecase",
|
|
11
|
+
"eventBus",
|
|
12
|
+
"job",
|
|
13
|
+
"schedule",
|
|
14
|
+
"provider",
|
|
15
|
+
"custom",
|
|
16
|
+
];
|
|
17
|
+
export function isDevtoolsEventType(value) {
|
|
18
|
+
return DEVTOOLS_EVENT_TYPES.includes(value);
|
|
19
|
+
}
|
|
20
|
+
//# sourceMappingURL=events.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"events.js","sourceRoot":"","sources":["../src/events.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AA4KH,MAAM,CAAC,MAAM,oBAAoB,GAAG;IAClC,SAAS;IACT,OAAO;IACP,SAAS;IACT,UAAU;IACV,KAAK;IACL,UAAU;IACV,UAAU;IACV,QAAQ;CAC2C,CAAC;AAEtD,MAAM,UAAU,mBAAmB,CACjC,KAAa;IAEb,OAAO,oBAAoB,CAAC,QAAQ,CAAC,KAA8B,CAAC,CAAC;AACvE,CAAC"}
|
package/dist/index.d.ts
ADDED
|
@@ -0,0 +1,114 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @beignet/devtools
|
|
3
|
+
*
|
|
4
|
+
* Development-time devtools for the Beignet server.
|
|
5
|
+
* Provides an in-memory event buffer and HTTP handlers to expose
|
|
6
|
+
* framework activity (requests, use cases, errors, events, jobs, schedules, providers).
|
|
7
|
+
*
|
|
8
|
+
* This package is intended for development and debugging only.
|
|
9
|
+
* It should not be used in production environments.
|
|
10
|
+
*
|
|
11
|
+
* @example
|
|
12
|
+
* ```ts
|
|
13
|
+
* import { createDevtoolsProvider } from "@beignet/devtools";
|
|
14
|
+
* import { createServer } from "@beignet/core/server";
|
|
15
|
+
*
|
|
16
|
+
* const server = await createServer({
|
|
17
|
+
* ports,
|
|
18
|
+
* providers: [createDevtoolsProvider(), ...otherProviders],
|
|
19
|
+
* });
|
|
20
|
+
*
|
|
21
|
+
* // In your code, log events:
|
|
22
|
+
* ctx.ports.devtools?.log({
|
|
23
|
+
* id: crypto.randomUUID(),
|
|
24
|
+
* type: "request",
|
|
25
|
+
* timestamp: new Date().toISOString(),
|
|
26
|
+
* method: "GET",
|
|
27
|
+
* path: "/api/users",
|
|
28
|
+
* });
|
|
29
|
+
* ```
|
|
30
|
+
*/
|
|
31
|
+
import type { ProviderInstrumentationPort } from "@beignet/core/providers";
|
|
32
|
+
import type { DevtoolsEvent, DevtoolsEventInput, DevtoolsListener } from "./events";
|
|
33
|
+
import type { DevtoolsWatcher, DevtoolsWatcherName } from "./watchers";
|
|
34
|
+
/**
|
|
35
|
+
* Filter options for querying devtools events.
|
|
36
|
+
*/
|
|
37
|
+
export interface DevtoolsFilter {
|
|
38
|
+
/**
|
|
39
|
+
* Filter by event type.
|
|
40
|
+
*/
|
|
41
|
+
type?: DevtoolsEvent["type"];
|
|
42
|
+
/**
|
|
43
|
+
* Filter by request correlation ID.
|
|
44
|
+
*/
|
|
45
|
+
requestId?: string;
|
|
46
|
+
/**
|
|
47
|
+
* Filter by W3C trace ID.
|
|
48
|
+
*/
|
|
49
|
+
traceId?: string;
|
|
50
|
+
/**
|
|
51
|
+
* Limit the number of results returned (default: 200).
|
|
52
|
+
*/
|
|
53
|
+
limit?: number;
|
|
54
|
+
}
|
|
55
|
+
/**
|
|
56
|
+
* Port interface for devtools.
|
|
57
|
+
*
|
|
58
|
+
* Apps and server internals can log framework events here during development.
|
|
59
|
+
* The events are stored in an in-memory buffer and can be retrieved via HTTP handlers.
|
|
60
|
+
*/
|
|
61
|
+
export interface DevtoolsPort extends ProviderInstrumentationPort<DevtoolsEventInput, DevtoolsWatcherName, DevtoolsEvent> {
|
|
62
|
+
/**
|
|
63
|
+
* Log a devtools event into the in-memory buffer.
|
|
64
|
+
*
|
|
65
|
+
* @param event - The event to log
|
|
66
|
+
*/
|
|
67
|
+
log(event: DevtoolsEvent): void;
|
|
68
|
+
/**
|
|
69
|
+
* Record an event and fill common fields such as id and timestamp.
|
|
70
|
+
*
|
|
71
|
+
* @param event - The event payload to record
|
|
72
|
+
* @returns The normalized event that was stored
|
|
73
|
+
*/
|
|
74
|
+
record(event: DevtoolsEventInput): DevtoolsEvent;
|
|
75
|
+
/**
|
|
76
|
+
* Subscribe to event buffer changes. Used by the live SSE endpoint.
|
|
77
|
+
*
|
|
78
|
+
* @param listener - Called when an event is recorded or the buffer is cleared
|
|
79
|
+
* @returns Cleanup function that removes the listener
|
|
80
|
+
*/
|
|
81
|
+
subscribe(listener: DevtoolsListener): () => void;
|
|
82
|
+
/**
|
|
83
|
+
* Retrieve recent events with optional filtering.
|
|
84
|
+
*
|
|
85
|
+
* @param filter - Optional filter to apply (type, requestId, limit)
|
|
86
|
+
* @returns Array of matching events
|
|
87
|
+
*/
|
|
88
|
+
getEvents(filter?: DevtoolsFilter): DevtoolsEvent[];
|
|
89
|
+
/**
|
|
90
|
+
* Clear all buffered events (dev-only).
|
|
91
|
+
*/
|
|
92
|
+
clear(): void | Promise<void>;
|
|
93
|
+
/**
|
|
94
|
+
* Return the watcher configuration installed for this devtools instance.
|
|
95
|
+
*/
|
|
96
|
+
getWatchers(): DevtoolsWatcher[];
|
|
97
|
+
/**
|
|
98
|
+
* Check whether a watcher is enabled.
|
|
99
|
+
*/
|
|
100
|
+
isWatcherEnabled(name: DevtoolsWatcherName): boolean;
|
|
101
|
+
}
|
|
102
|
+
export * from "./access";
|
|
103
|
+
export * from "./audit";
|
|
104
|
+
export * from "./events";
|
|
105
|
+
export * from "./instrumentation";
|
|
106
|
+
export * from "./persistence";
|
|
107
|
+
export * from "./provider";
|
|
108
|
+
export * from "./provider-instrumentation";
|
|
109
|
+
export * from "./redaction";
|
|
110
|
+
export * from "./routes";
|
|
111
|
+
export * from "./trace-context";
|
|
112
|
+
export * from "./ui";
|
|
113
|
+
export * from "./watchers";
|
|
114
|
+
//# sourceMappingURL=index.d.ts.map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,CAAC;AACzB,cAAc,SAAS,CAAC;AACxB,cAAc,UAAU,CAAC;AACzB,cAAc,mBAAmB,CAAC;AAClC,cAAc,eAAe,CAAC;AAC9B,cAAc,YAAY,CAAC;AAC3B,cAAc,4BAA4B,CAAC;AAC3C,cAAc,aAAa,CAAC;AAC5B,cAAc,UAAU,CAAC;AACzB,cAAc,iBAAiB,CAAC;AAChC,cAAc,MAAM,CAAC;AACrB,cAAc,YAAY,CAAC"}
|
package/dist/index.js
ADDED
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @beignet/devtools
|
|
3
|
+
*
|
|
4
|
+
* Development-time devtools for the Beignet server.
|
|
5
|
+
* Provides an in-memory event buffer and HTTP handlers to expose
|
|
6
|
+
* framework activity (requests, use cases, errors, events, jobs, schedules, providers).
|
|
7
|
+
*
|
|
8
|
+
* This package is intended for development and debugging only.
|
|
9
|
+
* It should not be used in production environments.
|
|
10
|
+
*
|
|
11
|
+
* @example
|
|
12
|
+
* ```ts
|
|
13
|
+
* import { createDevtoolsProvider } from "@beignet/devtools";
|
|
14
|
+
* import { createServer } from "@beignet/core/server";
|
|
15
|
+
*
|
|
16
|
+
* const server = await createServer({
|
|
17
|
+
* ports,
|
|
18
|
+
* providers: [createDevtoolsProvider(), ...otherProviders],
|
|
19
|
+
* });
|
|
20
|
+
*
|
|
21
|
+
* // In your code, log events:
|
|
22
|
+
* ctx.ports.devtools?.log({
|
|
23
|
+
* id: crypto.randomUUID(),
|
|
24
|
+
* type: "request",
|
|
25
|
+
* timestamp: new Date().toISOString(),
|
|
26
|
+
* method: "GET",
|
|
27
|
+
* path: "/api/users",
|
|
28
|
+
* });
|
|
29
|
+
* ```
|
|
30
|
+
*/
|
|
31
|
+
// Re-export everything
|
|
32
|
+
export * from "./access";
|
|
33
|
+
export * from "./audit";
|
|
34
|
+
export * from "./events";
|
|
35
|
+
export * from "./instrumentation";
|
|
36
|
+
export * from "./persistence";
|
|
37
|
+
export * from "./provider";
|
|
38
|
+
export * from "./provider-instrumentation";
|
|
39
|
+
export * from "./redaction";
|
|
40
|
+
export * from "./routes";
|
|
41
|
+
export * from "./trace-context";
|
|
42
|
+
export * from "./ui";
|
|
43
|
+
export * from "./watchers";
|
|
44
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA6BG;AA8FH,uBAAuB;AACvB,cAAc,UAAU,CAAC;AACzB,cAAc,SAAS,CAAC;AACxB,cAAc,UAAU,CAAC;AACzB,cAAc,mBAAmB,CAAC;AAClC,cAAc,eAAe,CAAC;AAC9B,cAAc,YAAY,CAAC;AAC3B,cAAc,4BAA4B,CAAC;AAC3C,cAAc,aAAa,CAAC;AAC5B,cAAc,UAAU,CAAC;AACzB,cAAc,iBAAiB,CAAC;AAChC,cAAc,MAAM,CAAC;AACrB,cAAc,YAAY,CAAC"}
|
|
@@ -0,0 +1,74 @@
|
|
|
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
|
+
export interface DevtoolsHooksOptions<Ctx> {
|
|
10
|
+
/**
|
|
11
|
+
* Devtools route prefix. Requests under this path are ignored to avoid
|
|
12
|
+
* filling the timeline with its own polling traffic.
|
|
13
|
+
*
|
|
14
|
+
* @default "/api/devtools"
|
|
15
|
+
*/
|
|
16
|
+
basePath?: string;
|
|
17
|
+
getRequestId?: (args: {
|
|
18
|
+
req: HttpRequestLike;
|
|
19
|
+
ctx?: Ctx;
|
|
20
|
+
response?: HttpResponseLike;
|
|
21
|
+
}) => string | undefined;
|
|
22
|
+
/**
|
|
23
|
+
* Response header used to expose the resolved request ID.
|
|
24
|
+
*
|
|
25
|
+
* Pass `false` to avoid writing a header.
|
|
26
|
+
*
|
|
27
|
+
* @default "x-request-id"
|
|
28
|
+
*/
|
|
29
|
+
requestIdHeader?: string | false;
|
|
30
|
+
/**
|
|
31
|
+
* W3C trace context header used to correlate devtools events with distributed
|
|
32
|
+
* traces.
|
|
33
|
+
*
|
|
34
|
+
* Pass `false` to avoid writing a header.
|
|
35
|
+
*
|
|
36
|
+
* @default "traceparent"
|
|
37
|
+
*/
|
|
38
|
+
traceContextHeader?: string | false;
|
|
39
|
+
getTraceContext?: (args: {
|
|
40
|
+
req: HttpRequestLike;
|
|
41
|
+
ctx?: Ctx;
|
|
42
|
+
response?: HttpResponseLike;
|
|
43
|
+
}) => DevtoolsTraceContextInput | string | undefined;
|
|
44
|
+
/**
|
|
45
|
+
* Apply a custom redactor to events produced by these hooks. The default
|
|
46
|
+
* devtools redactor still runs when events are stored.
|
|
47
|
+
*/
|
|
48
|
+
redact?: DevtoolsRedactor;
|
|
49
|
+
shouldCapture?: (args: {
|
|
50
|
+
req: HttpRequestLike;
|
|
51
|
+
ctx?: Ctx;
|
|
52
|
+
contract: HttpContractConfig;
|
|
53
|
+
response: HttpResponseLike;
|
|
54
|
+
error?: unknown;
|
|
55
|
+
}) => boolean;
|
|
56
|
+
}
|
|
57
|
+
export interface DevtoolsUseCaseRunEvent<Ctx> {
|
|
58
|
+
name: string;
|
|
59
|
+
kind: "command" | "query";
|
|
60
|
+
phase: "start" | "end" | "error";
|
|
61
|
+
durationMs?: number;
|
|
62
|
+
error?: unknown;
|
|
63
|
+
ctx: Ctx;
|
|
64
|
+
}
|
|
65
|
+
export interface DevtoolsUseCaseObserverOptions<Ctx> {
|
|
66
|
+
getDevtools?: (ctx: Ctx) => DevtoolsPort | undefined;
|
|
67
|
+
getRequestId?: (ctx: Ctx) => string | undefined;
|
|
68
|
+
logErrorEvents?: boolean;
|
|
69
|
+
redact?: DevtoolsRedactor;
|
|
70
|
+
}
|
|
71
|
+
export declare function createDevtoolsHooks<Ctx, Ports extends PortsWithDevtools = PortsWithDevtools>(options?: DevtoolsHooksOptions<Ctx>): ServerHook<Ctx, Ports>;
|
|
72
|
+
export declare function createDevtoolsUseCaseObserver<Ctx>(options?: DevtoolsUseCaseObserverOptions<Ctx>): (event: DevtoolsUseCaseRunEvent<Ctx>) => void;
|
|
73
|
+
export {};
|
|
74
|
+
//# sourceMappingURL=instrumentation.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
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,MAAM,WAAW,oBAAoB,CAAC,GAAG;IACvC;;;;;OAKG;IACH,QAAQ,CAAC,EAAE,MAAM,CAAC;IAElB,YAAY,CAAC,EAAE,CAAC,IAAI,EAAE;QACpB,GAAG,EAAE,eAAe,CAAC;QACrB,GAAG,CAAC,EAAE,GAAG,CAAC;QACV,QAAQ,CAAC,EAAE,gBAAgB,CAAC;KAC7B,KAAK,MAAM,GAAG,SAAS,CAAC;IAEzB;;;;;;OAMG;IACH,eAAe,CAAC,EAA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