@webda/debug 4.0.0-beta.3
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/LICENSE +166 -0
- package/README.md +95 -0
- package/lib/bodycapture.d.ts +66 -0
- package/lib/bodycapture.js +162 -0
- package/lib/bodycapture.js.map +1 -0
- package/lib/debugservice.service.d.ts +166 -0
- package/lib/debugservice.service.js +609 -0
- package/lib/debugservice.service.js.map +1 -0
- package/lib/index.d.ts +7 -0
- package/lib/index.js +7 -0
- package/lib/index.js.map +1 -0
- package/lib/introspection.d.ts +115 -0
- package/lib/introspection.js +260 -0
- package/lib/introspection.js.map +1 -0
- package/lib/logbuffer.d.ts +75 -0
- package/lib/logbuffer.js +98 -0
- package/lib/logbuffer.js.map +1 -0
- package/lib/requestlog.d.ts +181 -0
- package/lib/requestlog.js +153 -0
- package/lib/requestlog.js.map +1 -0
- package/lib/tui/client.d.ts +165 -0
- package/lib/tui/client.js +220 -0
- package/lib/tui/client.js.map +1 -0
- package/lib/tui/panels/config.d.ts +79 -0
- package/lib/tui/panels/config.js +291 -0
- package/lib/tui/panels/config.js.map +1 -0
- package/lib/tui/panels/logs.d.ts +106 -0
- package/lib/tui/panels/logs.js +342 -0
- package/lib/tui/panels/logs.js.map +1 -0
- package/lib/tui/panels/models.d.ts +47 -0
- package/lib/tui/panels/models.js +193 -0
- package/lib/tui/panels/models.js.map +1 -0
- package/lib/tui/panels/operations.d.ts +55 -0
- package/lib/tui/panels/operations.js +241 -0
- package/lib/tui/panels/operations.js.map +1 -0
- package/lib/tui/panels/panel.d.ts +55 -0
- package/lib/tui/panels/panel.js +31 -0
- package/lib/tui/panels/panel.js.map +1 -0
- package/lib/tui/panels/requests.d.ts +156 -0
- package/lib/tui/panels/requests.js +512 -0
- package/lib/tui/panels/requests.js.map +1 -0
- package/lib/tui/panels/routes.d.ts +45 -0
- package/lib/tui/panels/routes.js +154 -0
- package/lib/tui/panels/routes.js.map +1 -0
- package/lib/tui/panels/services.d.ts +49 -0
- package/lib/tui/panels/services.js +266 -0
- package/lib/tui/panels/services.js.map +1 -0
- package/lib/tui/tui.d.ts +58 -0
- package/lib/tui/tui.js +236 -0
- package/lib/tui/tui.js.map +1 -0
- package/package.json +60 -0
- package/webui/app.js +177 -0
- package/webui/components/logs.js +128 -0
- package/webui/components/model-graph.js +292 -0
- package/webui/components/models.js +213 -0
- package/webui/components/operations.js +315 -0
- package/webui/components/requests.js +264 -0
- package/webui/components/schema-form.js +268 -0
- package/webui/components/services.js +248 -0
- package/webui/index.html +22 -0
- package/webui/logo.svg +1 -0
- package/webui/styles.css +685 -0
- package/webui/vendor/htm.js +1 -0
- package/webui/vendor/preact-hooks.js +2 -0
- package/webui/vendor/preact.js +2 -0
- package/webui/webda.png +0 -0
|
@@ -0,0 +1,181 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The body of a captured request or response.
|
|
3
|
+
*
|
|
4
|
+
* - `text`: text payload that fit entirely within the configured size limit.
|
|
5
|
+
* - `text-truncated`: text payload truncated at the size limit; `content` is the prefix and `size` is the total byte count.
|
|
6
|
+
* - `binary`: binary payload — only `size` and a short hex `preview` are kept.
|
|
7
|
+
* - `empty`: no body at all.
|
|
8
|
+
*/
|
|
9
|
+
export type RequestLogBody = {
|
|
10
|
+
kind: "text";
|
|
11
|
+
content: string;
|
|
12
|
+
size: number;
|
|
13
|
+
} | {
|
|
14
|
+
kind: "text-truncated";
|
|
15
|
+
content: string;
|
|
16
|
+
size: number;
|
|
17
|
+
} | {
|
|
18
|
+
kind: "binary";
|
|
19
|
+
size: number;
|
|
20
|
+
preview: string;
|
|
21
|
+
} | {
|
|
22
|
+
kind: "empty";
|
|
23
|
+
};
|
|
24
|
+
/**
|
|
25
|
+
* Captured error attached to a request, when one was thrown.
|
|
26
|
+
*/
|
|
27
|
+
export interface RequestLogError {
|
|
28
|
+
message: string;
|
|
29
|
+
stack?: string;
|
|
30
|
+
}
|
|
31
|
+
/**
|
|
32
|
+
* A single entry in the request log
|
|
33
|
+
*/
|
|
34
|
+
export interface RequestLogEntry {
|
|
35
|
+
id: string;
|
|
36
|
+
method: string;
|
|
37
|
+
url: string;
|
|
38
|
+
timestamp: number;
|
|
39
|
+
statusCode?: number;
|
|
40
|
+
duration?: number;
|
|
41
|
+
/** Captured request headers (lowercased keys, single string values). */
|
|
42
|
+
requestHeaders?: Record<string, string>;
|
|
43
|
+
/** Captured request body. */
|
|
44
|
+
requestBody?: RequestLogBody;
|
|
45
|
+
/** Captured response headers (single string values). */
|
|
46
|
+
responseHeaders?: Record<string, string>;
|
|
47
|
+
/** Captured response body. */
|
|
48
|
+
responseBody?: RequestLogBody;
|
|
49
|
+
/** Captured error, if the request failed. */
|
|
50
|
+
error?: RequestLogError;
|
|
51
|
+
}
|
|
52
|
+
/**
|
|
53
|
+
* Summary fields returned by the list endpoint — keep this cheap (no bodies, no headers).
|
|
54
|
+
*/
|
|
55
|
+
export type RequestLogSummary = Pick<RequestLogEntry, "id" | "method" | "url" | "timestamp" | "statusCode" | "duration">;
|
|
56
|
+
/**
|
|
57
|
+
* Optional details that can be attached to an existing entry after capture.
|
|
58
|
+
*/
|
|
59
|
+
export interface RequestLogDetails {
|
|
60
|
+
requestHeaders?: Record<string, string>;
|
|
61
|
+
requestBody?: RequestLogBody;
|
|
62
|
+
responseHeaders?: Record<string, string>;
|
|
63
|
+
responseBody?: RequestLogBody;
|
|
64
|
+
error?: RequestLogError;
|
|
65
|
+
}
|
|
66
|
+
/**
|
|
67
|
+
* Events emitted by the RequestLog for request lifecycle changes
|
|
68
|
+
*/
|
|
69
|
+
export type RequestLogEvent = {
|
|
70
|
+
type: "request";
|
|
71
|
+
id: string;
|
|
72
|
+
method: string;
|
|
73
|
+
url: string;
|
|
74
|
+
timestamp: number;
|
|
75
|
+
} | {
|
|
76
|
+
type: "result";
|
|
77
|
+
id: string;
|
|
78
|
+
statusCode: number;
|
|
79
|
+
duration: number;
|
|
80
|
+
} | {
|
|
81
|
+
type: "404";
|
|
82
|
+
id: string;
|
|
83
|
+
method: string;
|
|
84
|
+
url: string;
|
|
85
|
+
};
|
|
86
|
+
type EventCallback = (event: RequestLogEvent) => void;
|
|
87
|
+
/**
|
|
88
|
+
* A fixed-size ring buffer that tracks HTTP requests and pushes lifecycle events to subscribers.
|
|
89
|
+
*
|
|
90
|
+
* When the buffer is full, the oldest entry is evicted to make room for the new one.
|
|
91
|
+
*/
|
|
92
|
+
export declare class RequestLog {
|
|
93
|
+
private maxSize;
|
|
94
|
+
private entries;
|
|
95
|
+
private index;
|
|
96
|
+
private subscribers;
|
|
97
|
+
/**
|
|
98
|
+
* Creates a new RequestLog.
|
|
99
|
+
*
|
|
100
|
+
* @param maxSize - Maximum number of entries to retain before evicting the oldest. Defaults to 1000.
|
|
101
|
+
*/
|
|
102
|
+
constructor(maxSize?: number);
|
|
103
|
+
/**
|
|
104
|
+
* Records the start of an incoming HTTP request.
|
|
105
|
+
*
|
|
106
|
+
* If the buffer is at capacity the oldest entry is removed first.
|
|
107
|
+
* A `"request"` event is pushed to all subscribers.
|
|
108
|
+
*
|
|
109
|
+
* @param id - Unique identifier for the request.
|
|
110
|
+
* @param method - HTTP method (e.g. "GET", "POST").
|
|
111
|
+
* @param url - Request URL.
|
|
112
|
+
*/
|
|
113
|
+
startRequest(id: string, method: string, url: string): void;
|
|
114
|
+
/**
|
|
115
|
+
* Records the completion of a previously started request.
|
|
116
|
+
*
|
|
117
|
+
* Updates the entry with the final status code and duration, then pushes a
|
|
118
|
+
* `"result"` event to all subscribers. Does nothing if the id is unknown.
|
|
119
|
+
*
|
|
120
|
+
* @param id - Unique identifier of the request.
|
|
121
|
+
* @param statusCode - HTTP response status code.
|
|
122
|
+
* @param duration - Request duration in milliseconds.
|
|
123
|
+
*/
|
|
124
|
+
completeRequest(id: string, statusCode: number, duration: number): void;
|
|
125
|
+
/**
|
|
126
|
+
* Marks a previously started request as a 404 Not Found response.
|
|
127
|
+
*
|
|
128
|
+
* Updates the entry's status code to 404 and pushes a `"404"` event to all
|
|
129
|
+
* subscribers. Does nothing if the id is unknown.
|
|
130
|
+
*
|
|
131
|
+
* @param id - Unique identifier of the request.
|
|
132
|
+
*/
|
|
133
|
+
markNotFound(id: string): void;
|
|
134
|
+
/**
|
|
135
|
+
* Attach captured headers, bodies, and/or error details to an existing entry.
|
|
136
|
+
*
|
|
137
|
+
* Merges the provided fields onto the entry. Does nothing (silently) if the
|
|
138
|
+
* id is unknown — the caller should call this only after `startRequest`.
|
|
139
|
+
*
|
|
140
|
+
* @param id - Unique identifier of the request.
|
|
141
|
+
* @param details - Captured details to attach.
|
|
142
|
+
*/
|
|
143
|
+
attachDetails(id: string, details: RequestLogDetails): void;
|
|
144
|
+
/**
|
|
145
|
+
* Returns a shallow copy of all currently stored entries in insertion order.
|
|
146
|
+
*
|
|
147
|
+
* Includes any captured headers, bodies, and error details.
|
|
148
|
+
*
|
|
149
|
+
* @returns Array of {@link RequestLogEntry} objects.
|
|
150
|
+
*/
|
|
151
|
+
getEntries(): RequestLogEntry[];
|
|
152
|
+
/**
|
|
153
|
+
* Returns lightweight summaries of all stored entries — no headers or bodies.
|
|
154
|
+
*
|
|
155
|
+
* Use this for the list view; use {@link getEntry} when the user drills in.
|
|
156
|
+
*
|
|
157
|
+
* @returns Array of {@link RequestLogSummary} objects in insertion order.
|
|
158
|
+
*/
|
|
159
|
+
getSummaries(): RequestLogSummary[];
|
|
160
|
+
/**
|
|
161
|
+
* Look up a single entry by id.
|
|
162
|
+
*
|
|
163
|
+
* @param id - Unique identifier of the request.
|
|
164
|
+
* @returns The entry, or `undefined` if not found.
|
|
165
|
+
*/
|
|
166
|
+
getEntry(id: string): RequestLogEntry | undefined;
|
|
167
|
+
/**
|
|
168
|
+
* Registers a callback that will be invoked for every future log event.
|
|
169
|
+
*
|
|
170
|
+
* @param callback - Function called with each {@link RequestLogEvent}.
|
|
171
|
+
* @returns An unsubscribe function. Call it to stop receiving events.
|
|
172
|
+
*/
|
|
173
|
+
onEvent(callback: EventCallback): () => void;
|
|
174
|
+
/**
|
|
175
|
+
* Dispatches an event to all current subscribers.
|
|
176
|
+
*
|
|
177
|
+
* @param event - The event to dispatch.
|
|
178
|
+
*/
|
|
179
|
+
private notify;
|
|
180
|
+
}
|
|
181
|
+
export {};
|
|
@@ -0,0 +1,153 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* A fixed-size ring buffer that tracks HTTP requests and pushes lifecycle events to subscribers.
|
|
3
|
+
*
|
|
4
|
+
* When the buffer is full, the oldest entry is evicted to make room for the new one.
|
|
5
|
+
*/
|
|
6
|
+
export class RequestLog {
|
|
7
|
+
/**
|
|
8
|
+
* Creates a new RequestLog.
|
|
9
|
+
*
|
|
10
|
+
* @param maxSize - Maximum number of entries to retain before evicting the oldest. Defaults to 1000.
|
|
11
|
+
*/
|
|
12
|
+
constructor(maxSize = 1000) {
|
|
13
|
+
this.maxSize = maxSize;
|
|
14
|
+
this.entries = [];
|
|
15
|
+
this.index = new Map();
|
|
16
|
+
this.subscribers = new Set();
|
|
17
|
+
}
|
|
18
|
+
/**
|
|
19
|
+
* Records the start of an incoming HTTP request.
|
|
20
|
+
*
|
|
21
|
+
* If the buffer is at capacity the oldest entry is removed first.
|
|
22
|
+
* A `"request"` event is pushed to all subscribers.
|
|
23
|
+
*
|
|
24
|
+
* @param id - Unique identifier for the request.
|
|
25
|
+
* @param method - HTTP method (e.g. "GET", "POST").
|
|
26
|
+
* @param url - Request URL.
|
|
27
|
+
*/
|
|
28
|
+
startRequest(id, method, url) {
|
|
29
|
+
const entry = { id, method, url, timestamp: Date.now() };
|
|
30
|
+
if (this.entries.length >= this.maxSize) {
|
|
31
|
+
const removed = this.entries.shift();
|
|
32
|
+
if (removed)
|
|
33
|
+
this.index.delete(removed.id);
|
|
34
|
+
}
|
|
35
|
+
this.entries.push(entry);
|
|
36
|
+
this.index.set(id, entry);
|
|
37
|
+
this.notify({ type: "request", id, method, url, timestamp: entry.timestamp });
|
|
38
|
+
}
|
|
39
|
+
/**
|
|
40
|
+
* Records the completion of a previously started request.
|
|
41
|
+
*
|
|
42
|
+
* Updates the entry with the final status code and duration, then pushes a
|
|
43
|
+
* `"result"` event to all subscribers. Does nothing if the id is unknown.
|
|
44
|
+
*
|
|
45
|
+
* @param id - Unique identifier of the request.
|
|
46
|
+
* @param statusCode - HTTP response status code.
|
|
47
|
+
* @param duration - Request duration in milliseconds.
|
|
48
|
+
*/
|
|
49
|
+
completeRequest(id, statusCode, duration) {
|
|
50
|
+
const entry = this.index.get(id);
|
|
51
|
+
if (!entry)
|
|
52
|
+
return;
|
|
53
|
+
entry.statusCode = statusCode;
|
|
54
|
+
entry.duration = duration;
|
|
55
|
+
this.notify({ type: "result", id, statusCode, duration });
|
|
56
|
+
}
|
|
57
|
+
/**
|
|
58
|
+
* Marks a previously started request as a 404 Not Found response.
|
|
59
|
+
*
|
|
60
|
+
* Updates the entry's status code to 404 and pushes a `"404"` event to all
|
|
61
|
+
* subscribers. Does nothing if the id is unknown.
|
|
62
|
+
*
|
|
63
|
+
* @param id - Unique identifier of the request.
|
|
64
|
+
*/
|
|
65
|
+
markNotFound(id) {
|
|
66
|
+
const entry = this.index.get(id);
|
|
67
|
+
if (!entry)
|
|
68
|
+
return;
|
|
69
|
+
entry.statusCode = 404;
|
|
70
|
+
this.notify({ type: "404", id, method: entry.method, url: entry.url });
|
|
71
|
+
}
|
|
72
|
+
/**
|
|
73
|
+
* Attach captured headers, bodies, and/or error details to an existing entry.
|
|
74
|
+
*
|
|
75
|
+
* Merges the provided fields onto the entry. Does nothing (silently) if the
|
|
76
|
+
* id is unknown — the caller should call this only after `startRequest`.
|
|
77
|
+
*
|
|
78
|
+
* @param id - Unique identifier of the request.
|
|
79
|
+
* @param details - Captured details to attach.
|
|
80
|
+
*/
|
|
81
|
+
attachDetails(id, details) {
|
|
82
|
+
const entry = this.index.get(id);
|
|
83
|
+
if (!entry)
|
|
84
|
+
return;
|
|
85
|
+
if (details.requestHeaders !== undefined)
|
|
86
|
+
entry.requestHeaders = details.requestHeaders;
|
|
87
|
+
if (details.requestBody !== undefined)
|
|
88
|
+
entry.requestBody = details.requestBody;
|
|
89
|
+
if (details.responseHeaders !== undefined)
|
|
90
|
+
entry.responseHeaders = details.responseHeaders;
|
|
91
|
+
if (details.responseBody !== undefined)
|
|
92
|
+
entry.responseBody = details.responseBody;
|
|
93
|
+
if (details.error !== undefined)
|
|
94
|
+
entry.error = details.error;
|
|
95
|
+
}
|
|
96
|
+
/**
|
|
97
|
+
* Returns a shallow copy of all currently stored entries in insertion order.
|
|
98
|
+
*
|
|
99
|
+
* Includes any captured headers, bodies, and error details.
|
|
100
|
+
*
|
|
101
|
+
* @returns Array of {@link RequestLogEntry} objects.
|
|
102
|
+
*/
|
|
103
|
+
getEntries() {
|
|
104
|
+
return [...this.entries];
|
|
105
|
+
}
|
|
106
|
+
/**
|
|
107
|
+
* Returns lightweight summaries of all stored entries — no headers or bodies.
|
|
108
|
+
*
|
|
109
|
+
* Use this for the list view; use {@link getEntry} when the user drills in.
|
|
110
|
+
*
|
|
111
|
+
* @returns Array of {@link RequestLogSummary} objects in insertion order.
|
|
112
|
+
*/
|
|
113
|
+
getSummaries() {
|
|
114
|
+
return this.entries.map(e => ({
|
|
115
|
+
id: e.id,
|
|
116
|
+
method: e.method,
|
|
117
|
+
url: e.url,
|
|
118
|
+
timestamp: e.timestamp,
|
|
119
|
+
statusCode: e.statusCode,
|
|
120
|
+
duration: e.duration
|
|
121
|
+
}));
|
|
122
|
+
}
|
|
123
|
+
/**
|
|
124
|
+
* Look up a single entry by id.
|
|
125
|
+
*
|
|
126
|
+
* @param id - Unique identifier of the request.
|
|
127
|
+
* @returns The entry, or `undefined` if not found.
|
|
128
|
+
*/
|
|
129
|
+
getEntry(id) {
|
|
130
|
+
return this.index.get(id);
|
|
131
|
+
}
|
|
132
|
+
/**
|
|
133
|
+
* Registers a callback that will be invoked for every future log event.
|
|
134
|
+
*
|
|
135
|
+
* @param callback - Function called with each {@link RequestLogEvent}.
|
|
136
|
+
* @returns An unsubscribe function. Call it to stop receiving events.
|
|
137
|
+
*/
|
|
138
|
+
onEvent(callback) {
|
|
139
|
+
this.subscribers.add(callback);
|
|
140
|
+
return () => this.subscribers.delete(callback);
|
|
141
|
+
}
|
|
142
|
+
/**
|
|
143
|
+
* Dispatches an event to all current subscribers.
|
|
144
|
+
*
|
|
145
|
+
* @param event - The event to dispatch.
|
|
146
|
+
*/
|
|
147
|
+
notify(event) {
|
|
148
|
+
for (const cb of this.subscribers) {
|
|
149
|
+
cb(event);
|
|
150
|
+
}
|
|
151
|
+
}
|
|
152
|
+
}
|
|
153
|
+
//# sourceMappingURL=requestlog.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"requestlog.js","sourceRoot":"","sources":["../src/requestlog.ts"],"names":[],"mappings":"AAwEA;;;;GAIG;AACH,MAAM,OAAO,UAAU;IAKrB;;;;OAIG;IACH,YAAoB,OAAO,GAAW,IAAI;QAAtB,YAAO,GAAP,OAAO,CAAe;QATlC,YAAO,GAAsB,EAAE,CAAC;QAChC,UAAK,GAAG,IAAI,GAAG,EAA2B,CAAC;QAC3C,gBAAW,GAAuB,IAAI,GAAG,EAAE,CAAC;IAOP,CAAC;IAE9C;;;;;;;;;OASG;IACH,YAAY,CAAC,EAAU,EAAE,MAAc,EAAE,GAAW;QAClD,MAAM,KAAK,GAAoB,EAAE,EAAE,EAAE,MAAM,EAAE,GAAG,EAAE,SAAS,EAAE,IAAI,CAAC,GAAG,EAAE,EAAE,CAAC;QAC1E,IAAI,IAAI,CAAC,OAAO,CAAC,MAAM,IAAI,IAAI,CAAC,OAAO,EAAE,CAAC;YACxC,MAAM,OAAO,GAAG,IAAI,CAAC,OAAO,CAAC,KAAK,EAAE,CAAC;YACrC,IAAI,OAAO;gBAAE,IAAI,CAAC,KAAK,CAAC,MAAM,CAAC,OAAO,CAAC,EAAE,CAAC,CAAC;QAC7C,CAAC;QACD,IAAI,CAAC,OAAO,CAAC,IAAI,CAAC,KA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,MAAM,CAAC,KAAsB;QACnC,KAAK,MAAM,EAAE,IAAI,IAAI,CAAC,WAAW,EAAE,CAAC;YAClC,EAAE,CAAC,KAAK,CAAC,CAAC;QACZ,CAAC;IACH,CAAC;CACF"}
|
|
@@ -0,0 +1,165 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Event types received over the WebSocket connection.
|
|
3
|
+
*/
|
|
4
|
+
export type WsEvent = {
|
|
5
|
+
type: "request";
|
|
6
|
+
id: string;
|
|
7
|
+
method: string;
|
|
8
|
+
url: string;
|
|
9
|
+
timestamp: number;
|
|
10
|
+
} | {
|
|
11
|
+
type: "result";
|
|
12
|
+
id: string;
|
|
13
|
+
statusCode: number;
|
|
14
|
+
duration: number;
|
|
15
|
+
} | {
|
|
16
|
+
type: "404";
|
|
17
|
+
id: string;
|
|
18
|
+
method: string;
|
|
19
|
+
url: string;
|
|
20
|
+
} | {
|
|
21
|
+
type: "restart";
|
|
22
|
+
} | {
|
|
23
|
+
type: "log";
|
|
24
|
+
level: string;
|
|
25
|
+
message: string;
|
|
26
|
+
timestamp: number;
|
|
27
|
+
};
|
|
28
|
+
/**
|
|
29
|
+
* Callback for WebSocket events.
|
|
30
|
+
*/
|
|
31
|
+
export type WsEventCallback = (event: WsEvent) => void;
|
|
32
|
+
/**
|
|
33
|
+
* HTTP + WebSocket client for the debug server API.
|
|
34
|
+
*
|
|
35
|
+
* Connects to the debug server started by `webda debug` and provides
|
|
36
|
+
* typed methods for each introspection endpoint, plus a reconnecting
|
|
37
|
+
* WebSocket subscription for live request events.
|
|
38
|
+
*/
|
|
39
|
+
export declare class DebugClient {
|
|
40
|
+
/** Base URL for HTTP requests (no trailing slash) */
|
|
41
|
+
private baseUrl;
|
|
42
|
+
/** Active WebSocket connection */
|
|
43
|
+
private ws?;
|
|
44
|
+
/** Whether the client should try to reconnect */
|
|
45
|
+
private shouldReconnect;
|
|
46
|
+
/** Current reconnect delay in ms */
|
|
47
|
+
private reconnectDelay;
|
|
48
|
+
/** Maximum reconnect delay in ms */
|
|
49
|
+
private maxReconnectDelay;
|
|
50
|
+
/** Event subscribers */
|
|
51
|
+
private subscribers;
|
|
52
|
+
/** Reconnect timer handle */
|
|
53
|
+
private reconnectTimer?;
|
|
54
|
+
/** Connection status */
|
|
55
|
+
private _connected;
|
|
56
|
+
/**
|
|
57
|
+
* Creates a new DebugClient.
|
|
58
|
+
*
|
|
59
|
+
* @param baseUrl - Base URL of the debug server, e.g. "http://localhost:18181"
|
|
60
|
+
*/
|
|
61
|
+
constructor(baseUrl?: string);
|
|
62
|
+
/**
|
|
63
|
+
* Whether the WebSocket is currently connected.
|
|
64
|
+
* @returns true if the WebSocket connection is open
|
|
65
|
+
*/
|
|
66
|
+
get connected(): boolean;
|
|
67
|
+
/**
|
|
68
|
+
* Fetch parsed JSON from a debug API endpoint.
|
|
69
|
+
*
|
|
70
|
+
* @param path - API path starting with /
|
|
71
|
+
* @returns Parsed JSON response
|
|
72
|
+
*/
|
|
73
|
+
private fetchJson;
|
|
74
|
+
/**
|
|
75
|
+
* Fetch all registered models.
|
|
76
|
+
* @returns array of model metadata objects
|
|
77
|
+
*/
|
|
78
|
+
getModels(): Promise<any[]>;
|
|
79
|
+
/**
|
|
80
|
+
* Fetch a single model by identifier.
|
|
81
|
+
*
|
|
82
|
+
* @param id - Fully-qualified model identifier
|
|
83
|
+
* @returns model metadata object
|
|
84
|
+
*/
|
|
85
|
+
getModel(id: string): Promise<any>;
|
|
86
|
+
/**
|
|
87
|
+
* Fetch all registered services.
|
|
88
|
+
* @returns array of service info objects
|
|
89
|
+
*/
|
|
90
|
+
getServices(): Promise<any[]>;
|
|
91
|
+
/**
|
|
92
|
+
* Fetch all registered operations.
|
|
93
|
+
* @returns array of operation info objects
|
|
94
|
+
*/
|
|
95
|
+
getOperations(): Promise<any[]>;
|
|
96
|
+
/**
|
|
97
|
+
* Fetch all registered routes.
|
|
98
|
+
* @returns array of route info objects
|
|
99
|
+
*/
|
|
100
|
+
getRoutes(): Promise<any[]>;
|
|
101
|
+
/**
|
|
102
|
+
* Fetch the resolved application configuration.
|
|
103
|
+
* @returns resolved configuration record
|
|
104
|
+
*/
|
|
105
|
+
getConfig(): Promise<Record<string, any>>;
|
|
106
|
+
/**
|
|
107
|
+
* Fetch the OpenAPI specification.
|
|
108
|
+
* @returns OpenAPI 3.0.3 document
|
|
109
|
+
*/
|
|
110
|
+
getOpenAPI(): Promise<Record<string, any>>;
|
|
111
|
+
/**
|
|
112
|
+
* Fetch recent request log entries (summary fields only — no headers/bodies).
|
|
113
|
+
* @returns array of request log entry summaries
|
|
114
|
+
*/
|
|
115
|
+
getRequests(): Promise<any[]>;
|
|
116
|
+
/**
|
|
117
|
+
* Fetch the full detail of a single request by id, including captured
|
|
118
|
+
* headers, bodies, and any error.
|
|
119
|
+
*
|
|
120
|
+
* @param id - The request id (as returned in the summary list).
|
|
121
|
+
* @returns The detailed request entry.
|
|
122
|
+
*/
|
|
123
|
+
getRequestDetail(id: string): Promise<any>;
|
|
124
|
+
/**
|
|
125
|
+
* Fetch recent application log entries.
|
|
126
|
+
* @returns array of log entries
|
|
127
|
+
*/
|
|
128
|
+
getLogs(): Promise<any[]>;
|
|
129
|
+
/**
|
|
130
|
+
* Fetch application info (package name, version, working directory).
|
|
131
|
+
* @returns project information record
|
|
132
|
+
*/
|
|
133
|
+
getAppInfo(): Promise<any>;
|
|
134
|
+
/**
|
|
135
|
+
* Search application log entries by query string.
|
|
136
|
+
*
|
|
137
|
+
* @param query - search text to filter logs
|
|
138
|
+
* @returns array of matching log entries
|
|
139
|
+
*/
|
|
140
|
+
searchLogs(query: string): Promise<any[]>;
|
|
141
|
+
/**
|
|
142
|
+
* Subscribe to WebSocket events.
|
|
143
|
+
*
|
|
144
|
+
* @param callback - Called for each event received
|
|
145
|
+
* @returns Unsubscribe function
|
|
146
|
+
*/
|
|
147
|
+
onEvent(callback: WsEventCallback): () => void;
|
|
148
|
+
/**
|
|
149
|
+
* Connect to the debug server WebSocket and begin receiving events.
|
|
150
|
+
* Automatically reconnects with exponential backoff on disconnect.
|
|
151
|
+
*/
|
|
152
|
+
connectWebSocket(): void;
|
|
153
|
+
/**
|
|
154
|
+
* Internal: establish the WebSocket connection.
|
|
155
|
+
*/
|
|
156
|
+
private doConnect;
|
|
157
|
+
/**
|
|
158
|
+
* Schedule a reconnection attempt with exponential backoff.
|
|
159
|
+
*/
|
|
160
|
+
private scheduleReconnect;
|
|
161
|
+
/**
|
|
162
|
+
* Disconnect the WebSocket and stop reconnecting.
|
|
163
|
+
*/
|
|
164
|
+
disconnect(): void;
|
|
165
|
+
}
|