app-devtools 0.31.0 → 1.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/dist/main.d.ts +194 -2
- package/dist/main.js +7019 -2711
- package/package.json +35 -35
package/dist/main.d.ts
CHANGED
|
@@ -1,11 +1,20 @@
|
|
|
1
|
+
/** opens the devtools panel, does nothing if it is already open */
|
|
2
|
+
declare function openDevTools(): void;
|
|
3
|
+
/** closes the devtools panel, does nothing if it is not open */
|
|
4
|
+
declare function closeDevTools(): void;
|
|
5
|
+
declare function toggleDevTools(): void;
|
|
6
|
+
declare function devToolsIsOpen(): boolean;
|
|
7
|
+
|
|
1
8
|
type RequestSubTypes = 'delete' | 'update' | 'create' | 'custom' | 'send' | 'receive';
|
|
2
9
|
type RequestTypes = 'ws' | 'fetch' | 'mutation';
|
|
10
|
+
type RequestStatus = 'pending' | 'success' | 'error';
|
|
3
11
|
type ApiRequest = {
|
|
4
12
|
id: string;
|
|
5
13
|
alias?: string;
|
|
6
14
|
payload: unknown;
|
|
7
15
|
response: unknown;
|
|
8
16
|
metadata: unknown;
|
|
17
|
+
status: RequestStatus;
|
|
9
18
|
isError: boolean;
|
|
10
19
|
path: string;
|
|
11
20
|
searchParams: Record<string, string> | null;
|
|
@@ -17,7 +26,36 @@ type ApiRequest = {
|
|
|
17
26
|
pathParams: Record<string, string | null> | null;
|
|
18
27
|
code: number | undefined;
|
|
19
28
|
tags: string[];
|
|
29
|
+
/**
|
|
30
|
+
* request headers, shown in the request details with values replaced by
|
|
31
|
+
* type descriptions (unless allowed by the `visibleRequestHeaders`
|
|
32
|
+
* config), full values are only used to generate the copy as cURL command
|
|
33
|
+
*/
|
|
34
|
+
headers: Record<string, string> | undefined;
|
|
35
|
+
/**
|
|
36
|
+
* warnings attached to the request, e.g. deprecated endpoint usage or
|
|
37
|
+
* slow responses, highlighted in the ui like errors are
|
|
38
|
+
*/
|
|
39
|
+
warnings: RequestWarning[] | undefined;
|
|
40
|
+
/**
|
|
41
|
+
* response fields that were not used by the app, an optimization
|
|
42
|
+
* opportunity shown in the stats tab
|
|
43
|
+
*/
|
|
44
|
+
unusedResponseData: string[] | undefined;
|
|
45
|
+
/**
|
|
46
|
+
* approximate stored size (json string length of payload/response/metadata
|
|
47
|
+
* plus a fixed overhead), used by the size-based eviction budget
|
|
48
|
+
*/
|
|
49
|
+
approxSize: number;
|
|
50
|
+
};
|
|
51
|
+
declare function addMarker(label?: string, time?: number): void;
|
|
52
|
+
declare function clearHistory(): void;
|
|
53
|
+
type RequestWarning = {
|
|
54
|
+
message: string;
|
|
55
|
+
/** optional structured data attached to the warning */
|
|
56
|
+
details?: unknown;
|
|
20
57
|
};
|
|
58
|
+
type RequestWarningInput = string | RequestWarning | null | undefined;
|
|
21
59
|
type Config = {
|
|
22
60
|
callsProcessor: {
|
|
23
61
|
match: ((request: {
|
|
@@ -35,6 +73,25 @@ type Config = {
|
|
|
35
73
|
}) => string;
|
|
36
74
|
payloadAlias?: (payload: any, request: ApiRequest) => string;
|
|
37
75
|
}[];
|
|
76
|
+
/**
|
|
77
|
+
* request header values are masked in the ui by default (replaced by type
|
|
78
|
+
* descriptions) as they may contain sensitive data, headers listed here
|
|
79
|
+
* (case-insensitive) show their raw values
|
|
80
|
+
*/
|
|
81
|
+
visibleRequestHeaders: string[];
|
|
82
|
+
/**
|
|
83
|
+
* payload fields with these names (at any nesting level) have their values
|
|
84
|
+
* masked in the ui (replaced by type descriptions), matching is
|
|
85
|
+
* case-insensitive and ignores `_` and `-` (e.g. `apiKey` also matches
|
|
86
|
+
* `api_key`)
|
|
87
|
+
*/
|
|
88
|
+
sensitiveDataFields: string[];
|
|
89
|
+
/**
|
|
90
|
+
* approximate max stored size (in MB, based on json string length) for
|
|
91
|
+
* requests across all call groups, oldest requests are evicted first to
|
|
92
|
+
* avoid memory issues in long-running sessions
|
|
93
|
+
*/
|
|
94
|
+
maxRequestsSizeMb: number;
|
|
38
95
|
};
|
|
39
96
|
type RegisterCallResult = (props: {
|
|
40
97
|
isError: boolean;
|
|
@@ -42,6 +99,17 @@ type RegisterCallResult = (props: {
|
|
|
42
99
|
response: unknown;
|
|
43
100
|
metadata?: unknown;
|
|
44
101
|
tags?: (string | null | undefined)[] | undefined;
|
|
102
|
+
/**
|
|
103
|
+
* warnings attached to the request, e.g. deprecated endpoint usage or
|
|
104
|
+
* slow responses, highlighted in the ui like errors are
|
|
105
|
+
*/
|
|
106
|
+
warnings?: RequestWarningInput[] | undefined;
|
|
107
|
+
/**
|
|
108
|
+
* response fields (e.g. object paths like `user.settings`) that were not
|
|
109
|
+
* used by the app, e.g. fields not declared in the response schema, shown
|
|
110
|
+
* in the stats tab as an optimization opportunity
|
|
111
|
+
*/
|
|
112
|
+
unusedResponseData?: (string | null | undefined)[] | undefined;
|
|
45
113
|
}) => void;
|
|
46
114
|
declare function addWebsocketEvent({ type, response, payload, event, startTime, }: {
|
|
47
115
|
type: 'send' | 'receive';
|
|
@@ -59,12 +127,136 @@ declare function addCall(request: {
|
|
|
59
127
|
startTime?: number;
|
|
60
128
|
duration?: number;
|
|
61
129
|
tags?: (string | null | undefined)[];
|
|
130
|
+
warnings?: RequestWarningInput[];
|
|
131
|
+
/**
|
|
132
|
+
* request headers, shown in the request details with values replaced by
|
|
133
|
+
* type descriptions (unless allowed by the `visibleRequestHeaders`
|
|
134
|
+
* config), full values are only used to generate the copy as cURL command
|
|
135
|
+
*/
|
|
136
|
+
headers?: Record<string, string | null | undefined>;
|
|
62
137
|
}): RegisterCallResult;
|
|
63
138
|
|
|
64
|
-
|
|
139
|
+
type RequestCallerResult = {
|
|
140
|
+
response: unknown;
|
|
141
|
+
status?: number;
|
|
142
|
+
isError?: boolean;
|
|
143
|
+
};
|
|
144
|
+
type RequestCallerSelectOption = string | {
|
|
145
|
+
value: string;
|
|
146
|
+
label: string;
|
|
147
|
+
};
|
|
148
|
+
/**
|
|
149
|
+
* An input rendered in the caller form. `json` inputs are validated and
|
|
150
|
+
* parsed, `string` and `select` values are passed as plain strings.
|
|
151
|
+
*/
|
|
152
|
+
type RequestCallerInput = {
|
|
153
|
+
type: 'json';
|
|
154
|
+
name: string;
|
|
155
|
+
label?: string;
|
|
156
|
+
placeholder?: string;
|
|
157
|
+
} | {
|
|
158
|
+
type: 'string';
|
|
159
|
+
name: string;
|
|
160
|
+
label?: string;
|
|
161
|
+
placeholder?: string;
|
|
162
|
+
} | {
|
|
163
|
+
type: 'select';
|
|
164
|
+
name: string;
|
|
165
|
+
label?: string;
|
|
166
|
+
options: RequestCallerSelectOption[];
|
|
167
|
+
};
|
|
168
|
+
/**
|
|
169
|
+
* A request caller configured by the lib consumer. It should abstract all
|
|
170
|
+
* app-specific details (auth, base url, headers, etc), receiving only the
|
|
171
|
+
* request path, method and payload.
|
|
172
|
+
*/
|
|
173
|
+
type RequestCaller = {
|
|
174
|
+
/** name shown in the caller selector */
|
|
175
|
+
name: string;
|
|
176
|
+
/** methods available in the UI, defaults to GET, POST, PUT, PATCH and DELETE */
|
|
177
|
+
methods?: string[];
|
|
178
|
+
/**
|
|
179
|
+
* inputs shown in the form, defaults to a single json input named
|
|
180
|
+
* `payload`, whose parsed value is passed directly as the call `payload`.
|
|
181
|
+
* With custom inputs, `payload` is a record with the value of each input
|
|
182
|
+
* keyed by its name (json input values are parsed, empty ones are omitted).
|
|
183
|
+
*/
|
|
184
|
+
inputs?: RequestCallerInput[];
|
|
185
|
+
/**
|
|
186
|
+
* maps a request opened from the network history into the form input
|
|
187
|
+
* values, keyed by input name. Defaults to putting the request payload
|
|
188
|
+
* JSON into the `payload` input, which matches the default inputs config.
|
|
189
|
+
* Configure it when using custom `inputs` that don't fit that mapping.
|
|
190
|
+
*/
|
|
191
|
+
mapRequestToInputs?: (request: {
|
|
192
|
+
path: string;
|
|
193
|
+
method: string;
|
|
194
|
+
payload: unknown;
|
|
195
|
+
}) => Record<string, string>;
|
|
196
|
+
call: (request: {
|
|
197
|
+
path: string;
|
|
198
|
+
method: string;
|
|
199
|
+
payload: unknown;
|
|
200
|
+
}) => Promise<RequestCallerResult>;
|
|
201
|
+
};
|
|
202
|
+
|
|
203
|
+
declare function initializeDevTools({ callsProcessor, shortcut, requestCallers, visibleRequestHeaders, sensitiveDataFields, maxRequestsSizeMb, maxLogsSizeMb, }: {
|
|
65
204
|
callsProcessor?: Config['callsProcessor'];
|
|
66
205
|
/** use $mod for CMD or Ctrl */
|
|
67
206
|
shortcut: string;
|
|
207
|
+
/**
|
|
208
|
+
* callers used by the request caller tab to perform requests using the
|
|
209
|
+
* consumer app data fetching mechanisms
|
|
210
|
+
*/
|
|
211
|
+
requestCallers?: RequestCaller[];
|
|
212
|
+
/**
|
|
213
|
+
* request header values are masked in the ui by default (replaced by type
|
|
214
|
+
* descriptions) as they may contain sensitive data, headers listed here
|
|
215
|
+
* (case-insensitive) show their raw values
|
|
216
|
+
*/
|
|
217
|
+
visibleRequestHeaders?: string[];
|
|
218
|
+
/**
|
|
219
|
+
* payload fields with these names (at any nesting level) have their values
|
|
220
|
+
* masked in the ui (replaced by type descriptions), matching is
|
|
221
|
+
* case-insensitive and ignores `_` and `-`, overrides the default list
|
|
222
|
+
* (token, password, secret, apiKey, etc)
|
|
223
|
+
*/
|
|
224
|
+
sensitiveDataFields?: string[];
|
|
225
|
+
/**
|
|
226
|
+
* approximate max stored size (in MB, based on json string length) for
|
|
227
|
+
* requests across all call groups, oldest requests are evicted first to
|
|
228
|
+
* avoid memory issues in long-running sessions (default: 30)
|
|
229
|
+
*/
|
|
230
|
+
maxRequestsSizeMb?: number;
|
|
231
|
+
/**
|
|
232
|
+
* approximate max stored size (in MB, based on json string length) for
|
|
233
|
+
* logs, oldest logs are evicted first to avoid memory issues in
|
|
234
|
+
* long-running sessions (default: 10)
|
|
235
|
+
*/
|
|
236
|
+
maxLogsSizeMb?: number;
|
|
237
|
+
}): void;
|
|
238
|
+
|
|
239
|
+
type LogSeverity = 'error' | 'warning' | 'info';
|
|
240
|
+
type DevtoolsLog = {
|
|
241
|
+
id: string;
|
|
242
|
+
severity: LogSeverity;
|
|
243
|
+
message: string;
|
|
244
|
+
category: string | undefined;
|
|
245
|
+
details: unknown;
|
|
246
|
+
time: number;
|
|
247
|
+
/**
|
|
248
|
+
* approximate stored size (json string length of message/details plus a
|
|
249
|
+
* fixed overhead), used by the size-based eviction budget
|
|
250
|
+
*/
|
|
251
|
+
approxSize: number;
|
|
252
|
+
};
|
|
253
|
+
declare function addLog(log: {
|
|
254
|
+
message: string;
|
|
255
|
+
severity?: LogSeverity;
|
|
256
|
+
category?: string;
|
|
257
|
+
details?: unknown;
|
|
258
|
+
time?: number;
|
|
68
259
|
}): void;
|
|
260
|
+
declare function clearLogs(): void;
|
|
69
261
|
|
|
70
|
-
export { RegisterCallResult, addCall, addWebsocketEvent, initializeDevTools };
|
|
262
|
+
export { type DevtoolsLog, type LogSeverity, type RegisterCallResult, type RequestCaller, type RequestCallerInput, type RequestCallerSelectOption, type RequestWarning, type RequestWarningInput, addCall, addLog, addMarker, addWebsocketEvent, clearHistory, clearLogs, closeDevTools, devToolsIsOpen, initializeDevTools, openDevTools, toggleDevTools };
|