@harborclient/sdk 0.4.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/README.md +41 -0
- package/dist/client.d.ts +2 -0
- package/dist/clipboard.d.ts +27 -0
- package/dist/clipboard.d.ts.map +1 -0
- package/dist/clipboard.js +17 -0
- package/dist/http/index.d.ts +3 -0
- package/dist/http/index.d.ts.map +1 -0
- package/dist/http/index.js +2 -0
- package/dist/http/resolveRequest.d.ts +66 -0
- package/dist/http/resolveRequest.d.ts.map +1 -0
- package/dist/http/resolveRequest.js +191 -0
- package/dist/http/resolveRequest.test.d.ts +2 -0
- package/dist/http/resolveRequest.test.d.ts.map +1 -0
- package/dist/http/resolveRequest.test.js +40 -0
- package/dist/http/substitute.d.ts +29 -0
- package/dist/http/substitute.d.ts.map +1 -0
- package/dist/http/substitute.js +43 -0
- package/dist/http/substitute.test.d.ts +2 -0
- package/dist/http/substitute.test.d.ts.map +1 -0
- package/dist/http/substitute.test.js +85 -0
- package/dist/index.d.ts +2 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +1 -0
- package/dist/main.d.ts +2 -0
- package/dist/main.d.ts.map +1 -0
- package/dist/main.js +1 -0
- package/dist/runtime/index.d.ts +20 -0
- package/dist/runtime/index.js +43 -0
- package/dist/runtime/jsx-dev-runtime.d.ts +12 -0
- package/dist/runtime/jsx-dev-runtime.js +15 -0
- package/dist/runtime/jsx-runtime.d.ts +35 -0
- package/dist/runtime/jsx-runtime.js +30 -0
- package/dist/runtime/react.d.ts +1 -0
- package/dist/runtime/react.js +46 -0
- package/dist/runtime/reactHost.js +26 -0
- package/dist/runtime/store.d.ts +19 -0
- package/dist/runtime/store.d.ts.map +1 -0
- package/dist/runtime/store.js +38 -0
- package/dist/runtime/store.ts +45 -0
- package/dist/runtime-utils.d.ts +36 -0
- package/dist/runtime-utils.d.ts.map +1 -0
- package/dist/runtime-utils.js +101 -0
- package/dist/runtime-utils.test.d.ts +2 -0
- package/dist/runtime-utils.test.d.ts.map +1 -0
- package/dist/runtime-utils.test.js +104 -0
- package/dist/signing/canonical.d.ts +27 -0
- package/dist/signing/canonical.d.ts.map +1 -0
- package/dist/signing/canonical.js +92 -0
- package/dist/signing/cli-sign.d.ts +3 -0
- package/dist/signing/cli-sign.d.ts.map +1 -0
- package/dist/signing/cli-sign.js +4 -0
- package/dist/signing/cli-verify.d.ts +3 -0
- package/dist/signing/cli-verify.d.ts.map +1 -0
- package/dist/signing/cli-verify.js +4 -0
- package/dist/signing/cli.d.ts +13 -0
- package/dist/signing/cli.d.ts.map +1 -0
- package/dist/signing/cli.js +148 -0
- package/dist/signing/index.d.ts +10 -0
- package/dist/signing/index.d.ts.map +1 -0
- package/dist/signing/index.js +7 -0
- package/dist/signing/inventory.d.ts +21 -0
- package/dist/signing/inventory.d.ts.map +1 -0
- package/dist/signing/inventory.js +80 -0
- package/dist/signing/manifest.d.ts +16 -0
- package/dist/signing/manifest.d.ts.map +1 -0
- package/dist/signing/manifest.js +33 -0
- package/dist/signing/sign.d.ts +10 -0
- package/dist/signing/sign.d.ts.map +1 -0
- package/dist/signing/sign.js +48 -0
- package/dist/signing/signing.test.d.ts +2 -0
- package/dist/signing/signing.test.d.ts.map +1 -0
- package/dist/signing/signing.test.js +100 -0
- package/dist/signing/testFixtures.d.ts +21 -0
- package/dist/signing/testFixtures.d.ts.map +1 -0
- package/dist/signing/testFixtures.js +41 -0
- package/dist/signing/types.d.ts +87 -0
- package/dist/signing/types.d.ts.map +1 -0
- package/dist/signing/types.js +12 -0
- package/dist/signing/verify.d.ts +17 -0
- package/dist/signing/verify.d.ts.map +1 -0
- package/dist/signing/verify.js +129 -0
- package/dist/storage/cappedList.d.ts +55 -0
- package/dist/storage/cappedList.d.ts.map +1 -0
- package/dist/storage/cappedList.js +102 -0
- package/dist/storage/cappedList.test.d.ts +2 -0
- package/dist/storage/cappedList.test.d.ts.map +1 -0
- package/dist/storage/cappedList.test.js +11 -0
- package/dist/storage/index.d.ts +2 -0
- package/dist/storage/index.d.ts.map +1 -0
- package/dist/storage/index.js +1 -0
- package/dist/types.d.ts +1282 -0
- package/dist/types.d.ts.map +1 -0
- package/dist/types.js +1 -0
- package/dist/ui/format.d.ts +23 -0
- package/dist/ui/format.d.ts.map +1 -0
- package/dist/ui/format.js +45 -0
- package/dist/ui/index.d.ts +3 -0
- package/dist/ui/index.d.ts.map +1 -0
- package/dist/ui/index.js +2 -0
- package/dist/ui/tokens.d.ts +34 -0
- package/dist/ui/tokens.d.ts.map +1 -0
- package/dist/ui/tokens.js +56 -0
- package/dist/utilities.test.d.ts +2 -0
- package/dist/utilities.test.d.ts.map +1 -0
- package/dist/utilities.test.js +16 -0
- package/package.json +130 -0
package/dist/types.d.ts
ADDED
|
@@ -0,0 +1,1282 @@
|
|
|
1
|
+
import type * as React from 'react';
|
|
2
|
+
/**
|
|
3
|
+
* A resource that can be released when no longer needed.
|
|
4
|
+
*
|
|
5
|
+
* Registration APIs (`hc.ui.register*`, `hc.themes.register`, `hc.commands.register`, etc.)
|
|
6
|
+
* return a `Disposable` that unregisters the contribution when {@link Disposable.dispose}
|
|
7
|
+
* is called. Push every returned disposable onto {@link PluginContext.subscriptions}
|
|
8
|
+
* so the host cleans up automatically on plugin deactivation.
|
|
9
|
+
*/
|
|
10
|
+
export interface Disposable {
|
|
11
|
+
/**
|
|
12
|
+
* Releases this registration and any resources it holds.
|
|
13
|
+
*/
|
|
14
|
+
dispose(): void;
|
|
15
|
+
}
|
|
16
|
+
/**
|
|
17
|
+
* Common fields shared by UI contribution types registered via {@link PluginUi}.
|
|
18
|
+
*
|
|
19
|
+
* The {@link UiContributionBase.id} must match an entry in the corresponding
|
|
20
|
+
* `manifest.contributes.*` array declared in your plugin package.
|
|
21
|
+
*/
|
|
22
|
+
export interface UiContributionBase {
|
|
23
|
+
/**
|
|
24
|
+
* Contribution id — must match an id in the corresponding manifest `contributes.*` array.
|
|
25
|
+
*/
|
|
26
|
+
id: string;
|
|
27
|
+
/**
|
|
28
|
+
* Display label shown in the target UI surface (Settings sidebar, tab strip, etc.).
|
|
29
|
+
*/
|
|
30
|
+
title: string;
|
|
31
|
+
}
|
|
32
|
+
/**
|
|
33
|
+
* Registers a React component as a Settings panel alongside built-in sections
|
|
34
|
+
* (General, Storage, and so on).
|
|
35
|
+
*
|
|
36
|
+
* Manifest: `contributes.settingsSections`. Requires the `ui` permission.
|
|
37
|
+
*/
|
|
38
|
+
export interface SettingsSectionContribution extends UiContributionBase {
|
|
39
|
+
/**
|
|
40
|
+
* Panel content rendered when the user selects this settings section. Use {@link PluginContext.react} — do not bundle React.
|
|
41
|
+
*/
|
|
42
|
+
Component: React.ComponentType;
|
|
43
|
+
}
|
|
44
|
+
/**
|
|
45
|
+
* Registers a switchable left sidebar destination — a full-height panel the user
|
|
46
|
+
* selects instead of the default collections view.
|
|
47
|
+
*
|
|
48
|
+
* Manifest: `contributes.sidebarPanels`. Requires the `ui` permission.
|
|
49
|
+
*/
|
|
50
|
+
export interface SidebarPanelContribution extends UiContributionBase {
|
|
51
|
+
/**
|
|
52
|
+
* Optional icon name shown when switching sidebar mode.
|
|
53
|
+
*/
|
|
54
|
+
icon?: string;
|
|
55
|
+
/**
|
|
56
|
+
* Full sidebar content for this panel. Use {@link PluginContext.react} — do not bundle React.
|
|
57
|
+
*/
|
|
58
|
+
Component: React.ComponentType;
|
|
59
|
+
/**
|
|
60
|
+
* Sort order among plugin sidebar panels. Lower values appear first.
|
|
61
|
+
*/
|
|
62
|
+
order?: number;
|
|
63
|
+
}
|
|
64
|
+
/**
|
|
65
|
+
* Adds a collapsible block inside the scrollable sidebar, using the same pattern
|
|
66
|
+
* as the built-in Collections and Environments sections.
|
|
67
|
+
*
|
|
68
|
+
* Manifest: `contributes.sidebarSections`. Requires the `ui` permission.
|
|
69
|
+
*/
|
|
70
|
+
export interface SidebarSectionContribution extends UiContributionBase {
|
|
71
|
+
/**
|
|
72
|
+
* Section body rendered below the collapsible heading. Use {@link PluginContext.react} — do not bundle React.
|
|
73
|
+
*/
|
|
74
|
+
Component: React.ComponentType;
|
|
75
|
+
/**
|
|
76
|
+
* Sort order below Collections / Environments. Lower values appear first.
|
|
77
|
+
*/
|
|
78
|
+
order?: number;
|
|
79
|
+
}
|
|
80
|
+
/**
|
|
81
|
+
* Registers a full main-area overlay, replacing the request editor while open
|
|
82
|
+
* (same pattern as Team Hubs or Sharing Keys). Open the view with
|
|
83
|
+
* {@link PluginCommands.execute} from a menu item or other trigger.
|
|
84
|
+
*
|
|
85
|
+
* Manifest: `contributes.mainViews`. Requires the `ui` permission.
|
|
86
|
+
*/
|
|
87
|
+
export interface MainViewContribution extends UiContributionBase {
|
|
88
|
+
/**
|
|
89
|
+
* Full main-area content. Use {@link PluginContext.react} — do not bundle React.
|
|
90
|
+
*/
|
|
91
|
+
Component: React.ComponentType;
|
|
92
|
+
}
|
|
93
|
+
/**
|
|
94
|
+
* Authorization type for the Auth tab; none inherits collection auth at send time.
|
|
95
|
+
*/
|
|
96
|
+
export type AuthType = 'none' | 'basic' | 'bearer';
|
|
97
|
+
/**
|
|
98
|
+
* Basic and bearer credential fields stored together so switching type preserves values.
|
|
99
|
+
*/
|
|
100
|
+
export interface AuthConfig {
|
|
101
|
+
/**
|
|
102
|
+
* Selected auth mode; none means no request-level override.
|
|
103
|
+
*/
|
|
104
|
+
type: AuthType;
|
|
105
|
+
/**
|
|
106
|
+
* Username and password for Basic Auth.
|
|
107
|
+
*/
|
|
108
|
+
basic: {
|
|
109
|
+
username: string;
|
|
110
|
+
password: string;
|
|
111
|
+
};
|
|
112
|
+
/**
|
|
113
|
+
* Token value for Bearer Token auth.
|
|
114
|
+
*/
|
|
115
|
+
bearer: {
|
|
116
|
+
token: string;
|
|
117
|
+
};
|
|
118
|
+
}
|
|
119
|
+
/**
|
|
120
|
+
* Request body encoding selected in the Body tab.
|
|
121
|
+
*/
|
|
122
|
+
export type BodyType = 'none' | 'json' | 'text' | 'multipart' | 'urlencoded';
|
|
123
|
+
/**
|
|
124
|
+
* Snapshot of the active request being edited in the request editor.
|
|
125
|
+
*
|
|
126
|
+
* Passed to request and response tab components via {@link RequestTabContext} and
|
|
127
|
+
* {@link ResponseTabContext}. Updates locally as the user edits — no IPC round-trip
|
|
128
|
+
* per keystroke.
|
|
129
|
+
*/
|
|
130
|
+
export interface RequestDraft {
|
|
131
|
+
/**
|
|
132
|
+
* HTTP method (for example `GET`, `POST`).
|
|
133
|
+
*/
|
|
134
|
+
method: string;
|
|
135
|
+
/**
|
|
136
|
+
* Request URL including scheme, host, path, and query string.
|
|
137
|
+
*/
|
|
138
|
+
url: string;
|
|
139
|
+
/**
|
|
140
|
+
* Query parameter rows. Each element has `key`, `value`, and `enabled` — only rows
|
|
141
|
+
* with `enabled: true` and a non-empty `key` are sent.
|
|
142
|
+
*/
|
|
143
|
+
params: Array<{
|
|
144
|
+
key: string;
|
|
145
|
+
value: string;
|
|
146
|
+
enabled: boolean;
|
|
147
|
+
}>;
|
|
148
|
+
/**
|
|
149
|
+
* Header rows. Each element has `key`, `value`, and `enabled` — only rows with
|
|
150
|
+
* `enabled: true` and a non-empty `key` are sent.
|
|
151
|
+
*/
|
|
152
|
+
headers: Array<{
|
|
153
|
+
key: string;
|
|
154
|
+
value: string;
|
|
155
|
+
enabled: boolean;
|
|
156
|
+
}>;
|
|
157
|
+
/**
|
|
158
|
+
* Request body content as a string.
|
|
159
|
+
*/
|
|
160
|
+
body: string;
|
|
161
|
+
/**
|
|
162
|
+
* Authorization settings from the Auth tab.
|
|
163
|
+
*/
|
|
164
|
+
auth: AuthConfig;
|
|
165
|
+
/**
|
|
166
|
+
* Body encoding selected in the Body tab.
|
|
167
|
+
*/
|
|
168
|
+
body_type: BodyType;
|
|
169
|
+
}
|
|
170
|
+
/**
|
|
171
|
+
* Snapshot of the last HTTP response received for the active request send.
|
|
172
|
+
*
|
|
173
|
+
* `null` on {@link RequestTabContext.response} and {@link ResponseTabContext.response}
|
|
174
|
+
* when no response exists yet.
|
|
175
|
+
*/
|
|
176
|
+
export interface HttpResponse {
|
|
177
|
+
/**
|
|
178
|
+
* HTTP status code (for example `200`, `404`).
|
|
179
|
+
*/
|
|
180
|
+
status: number;
|
|
181
|
+
/**
|
|
182
|
+
* HTTP status text (for example `OK`, `Not Found`).
|
|
183
|
+
*/
|
|
184
|
+
statusText: string;
|
|
185
|
+
/**
|
|
186
|
+
* Response header rows. Each element has `key` and `value`.
|
|
187
|
+
*/
|
|
188
|
+
headers: Array<{
|
|
189
|
+
key: string;
|
|
190
|
+
value: string;
|
|
191
|
+
}>;
|
|
192
|
+
/**
|
|
193
|
+
* Response body content as a string.
|
|
194
|
+
*/
|
|
195
|
+
body: string;
|
|
196
|
+
/**
|
|
197
|
+
* Time from send to response completion, in milliseconds.
|
|
198
|
+
*/
|
|
199
|
+
durationMs: number;
|
|
200
|
+
/**
|
|
201
|
+
* Response body size in bytes.
|
|
202
|
+
*/
|
|
203
|
+
sizeBytes: number;
|
|
204
|
+
}
|
|
205
|
+
/**
|
|
206
|
+
* Context passed to {@link RequestTabContribution} components.
|
|
207
|
+
*
|
|
208
|
+
* The tab re-renders locally when the user edits the request. Use
|
|
209
|
+
* {@link RequestTabContext.response} when you need the last response for the active send.
|
|
210
|
+
*/
|
|
211
|
+
export interface RequestTabContext {
|
|
212
|
+
/**
|
|
213
|
+
* Active request draft for the open editor tab.
|
|
214
|
+
*/
|
|
215
|
+
draft: RequestDraft;
|
|
216
|
+
/**
|
|
217
|
+
* Last response for the active send, or `null` if none yet.
|
|
218
|
+
*/
|
|
219
|
+
response: HttpResponse | null;
|
|
220
|
+
/**
|
|
221
|
+
* Always `true` — request tab content must not mutate the draft.
|
|
222
|
+
*/
|
|
223
|
+
readOnly: true;
|
|
224
|
+
/**
|
|
225
|
+
* Collection-level auth used when {@link RequestDraft.auth} type is `none`.
|
|
226
|
+
*/
|
|
227
|
+
collectionAuth: AuthConfig;
|
|
228
|
+
/**
|
|
229
|
+
* Collection-level headers merged before request headers at send time.
|
|
230
|
+
*/
|
|
231
|
+
collectionHeaders: Array<{
|
|
232
|
+
key: string;
|
|
233
|
+
value: string;
|
|
234
|
+
enabled: boolean;
|
|
235
|
+
}>;
|
|
236
|
+
/**
|
|
237
|
+
* Merged collection and environment values for {{key}} substitution.
|
|
238
|
+
*
|
|
239
|
+
* Environment overrides collection on duplicate keys. Empty variable values
|
|
240
|
+
* fall back to each variable's defaultValue (same as Send).
|
|
241
|
+
*/
|
|
242
|
+
variables: Record<string, string>;
|
|
243
|
+
}
|
|
244
|
+
/**
|
|
245
|
+
* Adds a segmented tab to the request editor (alongside Params, Headers, Body, and so on).
|
|
246
|
+
*
|
|
247
|
+
* Manifest: `contributes.requestTabs`. Requires the `ui` permission.
|
|
248
|
+
*/
|
|
249
|
+
export interface RequestTabContribution extends UiContributionBase {
|
|
250
|
+
/**
|
|
251
|
+
* Tab content. Receives `{ context: RequestTabContext }`. Use {@link PluginContext.react} — do not bundle React.
|
|
252
|
+
*/
|
|
253
|
+
Component: React.ComponentType<{
|
|
254
|
+
context: RequestTabContext;
|
|
255
|
+
}>;
|
|
256
|
+
/**
|
|
257
|
+
* Sort order among editor tabs. Lower values appear first.
|
|
258
|
+
*/
|
|
259
|
+
order?: number;
|
|
260
|
+
}
|
|
261
|
+
/**
|
|
262
|
+
* Context passed to {@link ResponseTabContribution} components.
|
|
263
|
+
*/
|
|
264
|
+
export interface ResponseTabContext {
|
|
265
|
+
/**
|
|
266
|
+
* Active request draft associated with the response viewer.
|
|
267
|
+
*/
|
|
268
|
+
draft: RequestDraft;
|
|
269
|
+
/**
|
|
270
|
+
* Last response, or `null` when no response exists yet.
|
|
271
|
+
*/
|
|
272
|
+
response: HttpResponse | null;
|
|
273
|
+
}
|
|
274
|
+
/**
|
|
275
|
+
* Adds a tab to the response viewer (alongside Body, Headers, Tests).
|
|
276
|
+
*
|
|
277
|
+
* Manifest: `contributes.responseTabs`. Requires the `ui` permission.
|
|
278
|
+
*/
|
|
279
|
+
export interface ResponseTabContribution extends UiContributionBase {
|
|
280
|
+
/**
|
|
281
|
+
* Tab content. Receives `{ context: ResponseTabContext }`. Use {@link PluginContext.react} — do not bundle React.
|
|
282
|
+
*/
|
|
283
|
+
Component: React.ComponentType<{
|
|
284
|
+
context: ResponseTabContext;
|
|
285
|
+
}>;
|
|
286
|
+
/**
|
|
287
|
+
* Sort order among response tabs. Lower values appear first.
|
|
288
|
+
*/
|
|
289
|
+
order?: number;
|
|
290
|
+
/**
|
|
291
|
+
* When the tab is visible. Default `'hasResponse'`.
|
|
292
|
+
*/
|
|
293
|
+
when?: 'always' | 'hasResponse';
|
|
294
|
+
}
|
|
295
|
+
/**
|
|
296
|
+
* Context passed to {@link CollectionSettingsTabContribution} components.
|
|
297
|
+
*/
|
|
298
|
+
export interface CollectionSettingsTabContext {
|
|
299
|
+
/**
|
|
300
|
+
* Database id of the collection whose settings are open.
|
|
301
|
+
*/
|
|
302
|
+
collectionId: number;
|
|
303
|
+
/**
|
|
304
|
+
* When `true`, the collection settings UI is read-only.
|
|
305
|
+
*/
|
|
306
|
+
readOnly: boolean;
|
|
307
|
+
}
|
|
308
|
+
/**
|
|
309
|
+
* Adds a segmented tab to Collection Settings (alongside General, Variables, Headers, and so on).
|
|
310
|
+
*
|
|
311
|
+
* Manifest: `contributes.collectionSettingsTabs`. Requires the `ui` permission.
|
|
312
|
+
*/
|
|
313
|
+
export interface CollectionSettingsTabContribution extends UiContributionBase {
|
|
314
|
+
/**
|
|
315
|
+
* Tab content. Receives `{ context: CollectionSettingsTabContext }`. Use {@link PluginContext.react} — do not bundle React.
|
|
316
|
+
*/
|
|
317
|
+
Component: React.ComponentType<{
|
|
318
|
+
context: CollectionSettingsTabContext;
|
|
319
|
+
}>;
|
|
320
|
+
/**
|
|
321
|
+
* Sort order among collection settings tabs. Lower values appear first.
|
|
322
|
+
*/
|
|
323
|
+
order?: number;
|
|
324
|
+
}
|
|
325
|
+
/**
|
|
326
|
+
* Registers a slide-up footer panel using the same pattern as Console and Variables.
|
|
327
|
+
*
|
|
328
|
+
* Manifest: `contributes.footerPanels`. Requires the `ui` permission.
|
|
329
|
+
*/
|
|
330
|
+
export interface FooterPanelContribution extends UiContributionBase {
|
|
331
|
+
/**
|
|
332
|
+
* Slide-up panel content. Use {@link PluginContext.react} — do not bundle React.
|
|
333
|
+
*/
|
|
334
|
+
Component: React.ComponentType;
|
|
335
|
+
}
|
|
336
|
+
/**
|
|
337
|
+
* Target application menu for {@link MenuItemContribution} entries.
|
|
338
|
+
*
|
|
339
|
+
* Menu contributions use the application menu only — not native window chrome.
|
|
340
|
+
*/
|
|
341
|
+
export type AppMenu = 'file' | 'edit' | 'view' | 'help';
|
|
342
|
+
/**
|
|
343
|
+
* Adds an item to an application menu (File, Edit, View, or Help).
|
|
344
|
+
*
|
|
345
|
+
* Register the command handler with {@link PluginCommands.register} separately.
|
|
346
|
+
* Manifest: `contributes.menus` plus a matching `contributes.commands` entry.
|
|
347
|
+
* Requires the `ui` permission.
|
|
348
|
+
*/
|
|
349
|
+
export interface MenuItemContribution {
|
|
350
|
+
/**
|
|
351
|
+
* Target application menu.
|
|
352
|
+
*/
|
|
353
|
+
menu: AppMenu;
|
|
354
|
+
/**
|
|
355
|
+
* Command id to run on click — must match a registered command and manifest entry.
|
|
356
|
+
*/
|
|
357
|
+
command: string;
|
|
358
|
+
/**
|
|
359
|
+
* Menu label override. Falls back to the command title when omitted.
|
|
360
|
+
*/
|
|
361
|
+
label?: string;
|
|
362
|
+
/**
|
|
363
|
+
* Menu group for separator placement.
|
|
364
|
+
*/
|
|
365
|
+
group?: string;
|
|
366
|
+
/**
|
|
367
|
+
* Sort order within the group. Lower values appear first.
|
|
368
|
+
*/
|
|
369
|
+
order?: number;
|
|
370
|
+
}
|
|
371
|
+
/**
|
|
372
|
+
* Adds a button to the request URL bar toolbar near the Send button.
|
|
373
|
+
*
|
|
374
|
+
* Register the command handler with {@link PluginCommands.register} separately.
|
|
375
|
+
* Manifest: `contributes.requestToolbarActions` plus a matching `contributes.commands` entry.
|
|
376
|
+
* Requires the `ui` permission.
|
|
377
|
+
*/
|
|
378
|
+
export interface RequestToolbarActionContribution {
|
|
379
|
+
/**
|
|
380
|
+
* Action id — must match an entry in `contributes.requestToolbarActions`.
|
|
381
|
+
*/
|
|
382
|
+
id: string;
|
|
383
|
+
/**
|
|
384
|
+
* Button label or tooltip text.
|
|
385
|
+
*/
|
|
386
|
+
title: string;
|
|
387
|
+
/**
|
|
388
|
+
* Command id to run on click — must match a registered command and manifest entry.
|
|
389
|
+
*/
|
|
390
|
+
command: string;
|
|
391
|
+
/**
|
|
392
|
+
* Optional icon name.
|
|
393
|
+
*/
|
|
394
|
+
icon?: string;
|
|
395
|
+
/**
|
|
396
|
+
* Sort order near the Send button. Lower values appear first.
|
|
397
|
+
*/
|
|
398
|
+
order?: number;
|
|
399
|
+
}
|
|
400
|
+
/**
|
|
401
|
+
* Sidebar row type that a context menu item applies to.
|
|
402
|
+
*
|
|
403
|
+
* Used by {@link ContextMenuItemContribution.when} to filter which rows show the action.
|
|
404
|
+
*/
|
|
405
|
+
export type ContextMenuTarget = 'collection' | 'folder' | 'request';
|
|
406
|
+
/**
|
|
407
|
+
* Adds an action to row context menus in the sidebar.
|
|
408
|
+
*
|
|
409
|
+
* The command handler receives target context as arguments (for example `requestId`).
|
|
410
|
+
* Register the handler with {@link PluginCommands.register} separately.
|
|
411
|
+
* Manifest: `contributes.contextMenus` plus a matching `contributes.commands` entry.
|
|
412
|
+
* Requires the `ui` permission.
|
|
413
|
+
*/
|
|
414
|
+
export interface ContextMenuItemContribution {
|
|
415
|
+
/**
|
|
416
|
+
* Menu item id — must match an entry in `contributes.contextMenus`.
|
|
417
|
+
*/
|
|
418
|
+
id: string;
|
|
419
|
+
/**
|
|
420
|
+
* Menu label shown in the context menu.
|
|
421
|
+
*/
|
|
422
|
+
title: string;
|
|
423
|
+
/**
|
|
424
|
+
* Command id to run on click — must match a registered command and manifest entry.
|
|
425
|
+
*/
|
|
426
|
+
command: string;
|
|
427
|
+
/**
|
|
428
|
+
* Sidebar row type(s) that show this menu item.
|
|
429
|
+
*/
|
|
430
|
+
when: ContextMenuTarget | ContextMenuTarget[];
|
|
431
|
+
/**
|
|
432
|
+
* Menu group for separator placement.
|
|
433
|
+
*/
|
|
434
|
+
group?: string;
|
|
435
|
+
/**
|
|
436
|
+
* Sort order within the group. Lower values appear first.
|
|
437
|
+
*/
|
|
438
|
+
order?: number;
|
|
439
|
+
}
|
|
440
|
+
/**
|
|
441
|
+
* Adds a custom status indicator to the footer bar (beside sidebar / AI toggles).
|
|
442
|
+
*
|
|
443
|
+
* Manifest: `contributes.statusBarItems`. Requires the `ui` permission.
|
|
444
|
+
*/
|
|
445
|
+
export interface StatusBarItemContribution {
|
|
446
|
+
/**
|
|
447
|
+
* Item id — must match an entry in `contributes.statusBarItems`.
|
|
448
|
+
*/
|
|
449
|
+
id: string;
|
|
450
|
+
/**
|
|
451
|
+
* Status content rendered in the footer. Use {@link PluginContext.react} — do not bundle React.
|
|
452
|
+
*/
|
|
453
|
+
Component: React.ComponentType;
|
|
454
|
+
/**
|
|
455
|
+
* Footer side. Default `'right'`.
|
|
456
|
+
*/
|
|
457
|
+
alignment?: 'left' | 'right';
|
|
458
|
+
/**
|
|
459
|
+
* Sort order on that side. Lower values appear first.
|
|
460
|
+
*/
|
|
461
|
+
order?: number;
|
|
462
|
+
}
|
|
463
|
+
/**
|
|
464
|
+
* HarborClient UI color token ids.
|
|
465
|
+
*
|
|
466
|
+
* Override via {@link ThemeContribution.colors} or a bundled stylesheet.
|
|
467
|
+
* Each token maps to a `--mac-<token>` CSS custom property on `:root`.
|
|
468
|
+
*
|
|
469
|
+
* Token usage:
|
|
470
|
+
* - `surface` — main content background
|
|
471
|
+
* - `sidebar` — left sidebar background
|
|
472
|
+
* - `sidebar-section` — sidebar section headers
|
|
473
|
+
* - `control` — panels, inputs, footer bar
|
|
474
|
+
* - `field` — input field fill
|
|
475
|
+
* - `separator` — borders and dividers
|
|
476
|
+
* - `text` — primary text
|
|
477
|
+
* - `text-secondary` — secondary labels
|
|
478
|
+
* - `muted` — de-emphasized text
|
|
479
|
+
* - `accent` — links, focus rings, primary actions
|
|
480
|
+
* - `selection` — selected row / highlight fill
|
|
481
|
+
* - `danger`, `danger-light`, `warning`, `success`, `info` — status colors
|
|
482
|
+
* - `method-get`, `method-post`, `method-put`, `method-patch`, `method-delete`, `method-head`, `method-options` — HTTP method badge colors
|
|
483
|
+
*/
|
|
484
|
+
export type ThemeColorToken = 'surface' | 'sidebar' | 'sidebar-section' | 'control' | 'field' | 'separator' | 'text' | 'text-secondary' | 'muted' | 'accent' | 'selection' | 'danger' | 'danger-light' | 'warning' | 'success' | 'info' | 'method-get' | 'method-post' | 'method-put' | 'method-patch' | 'method-delete' | 'method-head' | 'method-options';
|
|
485
|
+
/**
|
|
486
|
+
* Custom appearance theme registered via {@link PluginThemes.register}.
|
|
487
|
+
*
|
|
488
|
+
* Plugin themes appear in **Settings → General → Appearance** alongside built-in options.
|
|
489
|
+
* When active, the host sets `data-theme="plugin-<pluginId>-<themeId>"` on `<html>` and
|
|
490
|
+
* applies token overrides or an injected stylesheet.
|
|
491
|
+
*
|
|
492
|
+
* Manifest: `contributes.themes`. Requires the `ui` permission.
|
|
493
|
+
*/
|
|
494
|
+
export interface ThemeContribution {
|
|
495
|
+
/**
|
|
496
|
+
* Theme id unique within your plugin — must match an entry in `contributes.themes`.
|
|
497
|
+
*/
|
|
498
|
+
id: string;
|
|
499
|
+
/**
|
|
500
|
+
* Label shown in the appearance dropdown.
|
|
501
|
+
*/
|
|
502
|
+
title: string;
|
|
503
|
+
/**
|
|
504
|
+
* Base appearance for `color-scheme` and Electron native window chrome.
|
|
505
|
+
*/
|
|
506
|
+
type: 'light' | 'dark';
|
|
507
|
+
/**
|
|
508
|
+
* Token overrides without the `--mac-` prefix. Use for simple palette swaps.
|
|
509
|
+
*/
|
|
510
|
+
colors?: Partial<Record<ThemeColorToken, string>>;
|
|
511
|
+
/**
|
|
512
|
+
* Plugin-relative CSS path (for example `dist/theme.css`) for complex themes.
|
|
513
|
+
*/
|
|
514
|
+
stylesheet?: string;
|
|
515
|
+
}
|
|
516
|
+
/**
|
|
517
|
+
* Built-in appearance theme ids selectable in **Settings → General**.
|
|
518
|
+
*
|
|
519
|
+
* When a built-in theme is active, plugin theme overrides are not applied.
|
|
520
|
+
*/
|
|
521
|
+
export type BuiltinThemeId = 'light' | 'dark' | 'system' | 'high-contrast';
|
|
522
|
+
/**
|
|
523
|
+
* Currently active appearance theme — either a built-in HarborClient theme or a plugin theme.
|
|
524
|
+
*
|
|
525
|
+
* When the user selects a plugin theme, the persisted value is
|
|
526
|
+
* `plugin:<pluginId>:<themeId>`. If the plugin is disabled or uninstalled while its
|
|
527
|
+
* theme is active, HarborClient falls back to **System**.
|
|
528
|
+
*/
|
|
529
|
+
export type ActiveTheme = {
|
|
530
|
+
/**
|
|
531
|
+
* Theme provided by HarborClient.
|
|
532
|
+
*/
|
|
533
|
+
source: 'builtin';
|
|
534
|
+
/**
|
|
535
|
+
* Built-in theme id.
|
|
536
|
+
*/
|
|
537
|
+
id: BuiltinThemeId;
|
|
538
|
+
} | {
|
|
539
|
+
/**
|
|
540
|
+
* Theme registered by a plugin via {@link PluginThemes.register}.
|
|
541
|
+
*/
|
|
542
|
+
source: 'plugin';
|
|
543
|
+
/**
|
|
544
|
+
* Plugin package id from `manifest.json`.
|
|
545
|
+
*/
|
|
546
|
+
pluginId: string;
|
|
547
|
+
/**
|
|
548
|
+
* Theme id from {@link ThemeContribution.id}.
|
|
549
|
+
*/
|
|
550
|
+
themeId: string;
|
|
551
|
+
};
|
|
552
|
+
/**
|
|
553
|
+
* Custom appearance theme registration and change notifications.
|
|
554
|
+
*
|
|
555
|
+
* Requires the `ui` permission. Push returned disposables onto
|
|
556
|
+
* {@link PluginContext.subscriptions}.
|
|
557
|
+
*/
|
|
558
|
+
export interface PluginThemes {
|
|
559
|
+
/**
|
|
560
|
+
* Registers a custom appearance theme.
|
|
561
|
+
*
|
|
562
|
+
* Provide {@link ThemeContribution.colors}, a {@link ThemeContribution.stylesheet}, or both.
|
|
563
|
+
* The host injects stylesheets while the theme is registered and removes them on deactivation.
|
|
564
|
+
*
|
|
565
|
+
* @param theme - Theme definition. `theme.id` must match `contributes.themes`.
|
|
566
|
+
* @returns A {@link Disposable} that unregisters the theme when disposed.
|
|
567
|
+
*/
|
|
568
|
+
register(theme: ThemeContribution): Disposable;
|
|
569
|
+
/**
|
|
570
|
+
* Returns the currently active theme.
|
|
571
|
+
*
|
|
572
|
+
* @returns The active built-in or plugin theme reference.
|
|
573
|
+
*/
|
|
574
|
+
getActive(): Promise<ActiveTheme>;
|
|
575
|
+
/**
|
|
576
|
+
* Fires when the user changes the appearance theme in Settings or when the host
|
|
577
|
+
* resets the theme after plugin deactivation.
|
|
578
|
+
*
|
|
579
|
+
* @param listener - Called with the new {@link ActiveTheme}.
|
|
580
|
+
* @returns A {@link Disposable} that removes the listener when disposed.
|
|
581
|
+
*/
|
|
582
|
+
onDidChange(listener: (theme: ActiveTheme) => void): Disposable;
|
|
583
|
+
}
|
|
584
|
+
/**
|
|
585
|
+
* Plugin-scoped persistent key-value storage backed by the main process.
|
|
586
|
+
*
|
|
587
|
+
* Keys are namespaced by plugin `id`. Requires the `storage` permission.
|
|
588
|
+
* Use for settings and preferences — debounce text-field writes; load once on panel mount.
|
|
589
|
+
*/
|
|
590
|
+
export interface PluginStorage {
|
|
591
|
+
/**
|
|
592
|
+
* Returns the stored value for a key.
|
|
593
|
+
*
|
|
594
|
+
* @param key - Storage key within this plugin's namespace.
|
|
595
|
+
* @returns The stored value, or `undefined` if the key has never been set.
|
|
596
|
+
*/
|
|
597
|
+
get<T>(key: string): Promise<T | undefined>;
|
|
598
|
+
/**
|
|
599
|
+
* Persists a JSON-serializable value.
|
|
600
|
+
*
|
|
601
|
+
* @param key - Storage key within this plugin's namespace.
|
|
602
|
+
* @param value - Value to persist.
|
|
603
|
+
*/
|
|
604
|
+
set<T>(key: string, value: T): Promise<void>;
|
|
605
|
+
}
|
|
606
|
+
/**
|
|
607
|
+
* Command handlers that tie together menus, toolbar actions, and context menu items.
|
|
608
|
+
*
|
|
609
|
+
* Requires the `ui` permission for {@link PluginCommands.register}. Push returned
|
|
610
|
+
* disposables onto {@link PluginContext.subscriptions}.
|
|
611
|
+
*/
|
|
612
|
+
export interface PluginCommands {
|
|
613
|
+
/**
|
|
614
|
+
* Registers a command handler.
|
|
615
|
+
*
|
|
616
|
+
* The `id` must match a command declared in `manifest.contributes.commands` and
|
|
617
|
+
* referenced by menu, toolbar, or context menu contributions.
|
|
618
|
+
*
|
|
619
|
+
* @param id - Command id.
|
|
620
|
+
* @param handler - Called when the command runs. Context menu handlers receive target context as args.
|
|
621
|
+
* @returns A {@link Disposable} that unregisters the handler when disposed.
|
|
622
|
+
*/
|
|
623
|
+
register(id: string, handler: (...args: unknown[]) => void | Promise<void>): Disposable;
|
|
624
|
+
/**
|
|
625
|
+
* Runs a registered command programmatically.
|
|
626
|
+
*
|
|
627
|
+
* For example, open a {@link MainViewContribution} from another part of your plugin.
|
|
628
|
+
*
|
|
629
|
+
* @param id - Command id to execute.
|
|
630
|
+
* @param args - Arguments forwarded to the command handler.
|
|
631
|
+
*/
|
|
632
|
+
execute(id: string, ...args: unknown[]): Promise<void>;
|
|
633
|
+
}
|
|
634
|
+
/**
|
|
635
|
+
* Options for picking a file through {@link PluginFs.pickFile}.
|
|
636
|
+
*/
|
|
637
|
+
export interface PluginFsPickFileOptions {
|
|
638
|
+
/**
|
|
639
|
+
* Dialog title.
|
|
640
|
+
*/
|
|
641
|
+
title?: string;
|
|
642
|
+
/**
|
|
643
|
+
* File extension filters.
|
|
644
|
+
*/
|
|
645
|
+
filters?: Array<{
|
|
646
|
+
name: string;
|
|
647
|
+
extensions: string[];
|
|
648
|
+
}>;
|
|
649
|
+
/**
|
|
650
|
+
* Allow multiple file selection.
|
|
651
|
+
*/
|
|
652
|
+
multiple?: boolean;
|
|
653
|
+
}
|
|
654
|
+
/**
|
|
655
|
+
* Options for saving a file through {@link PluginFs.saveFile}.
|
|
656
|
+
*/
|
|
657
|
+
export interface PluginFsSaveFileOptions {
|
|
658
|
+
/**
|
|
659
|
+
* Suggested file name or path.
|
|
660
|
+
*/
|
|
661
|
+
defaultPath?: string;
|
|
662
|
+
/**
|
|
663
|
+
* File extension filters.
|
|
664
|
+
*/
|
|
665
|
+
filters?: Array<{
|
|
666
|
+
name: string;
|
|
667
|
+
extensions: string[];
|
|
668
|
+
}>;
|
|
669
|
+
}
|
|
670
|
+
/**
|
|
671
|
+
* Plugin-scoped filesystem access backed by main-process permission checks and a
|
|
672
|
+
* per-plugin path allowlist.
|
|
673
|
+
*
|
|
674
|
+
* Requires `filesystem:pick` for open/save dialogs, `filesystem:read` for
|
|
675
|
+
* {@link PluginFs.readFile}, and `filesystem:write` for {@link PluginFs.writeFile}.
|
|
676
|
+
* User-selected paths from pick/save dialogs are added to the allowlist automatically;
|
|
677
|
+
* the plugin package directory is allowlisted on load.
|
|
678
|
+
*/
|
|
679
|
+
export interface PluginFs {
|
|
680
|
+
/**
|
|
681
|
+
* Opens a native file picker. Returns absolute paths for selected files, or an
|
|
682
|
+
* empty array when the dialog is canceled. Requires the `filesystem:pick` permission.
|
|
683
|
+
*
|
|
684
|
+
* @param options - Optional dialog configuration.
|
|
685
|
+
*/
|
|
686
|
+
pickFile: (options?: PluginFsPickFileOptions) => Promise<string[]>;
|
|
687
|
+
/**
|
|
688
|
+
* Opens a native directory picker. Returns the selected directory path, or `null`
|
|
689
|
+
* when canceled. Requires the `filesystem:pick` permission.
|
|
690
|
+
*
|
|
691
|
+
* @param defaultPath - Optional starting directory.
|
|
692
|
+
*/
|
|
693
|
+
pickDirectory: (defaultPath?: string) => Promise<string | null>;
|
|
694
|
+
/**
|
|
695
|
+
* Opens a native save dialog and writes content to the chosen path. Returns the
|
|
696
|
+
* saved path, or `null` when canceled. Requires `filesystem:pick` and
|
|
697
|
+
* `filesystem:write` permissions.
|
|
698
|
+
*
|
|
699
|
+
* @param content - UTF-8 text to write.
|
|
700
|
+
* @param options - Optional dialog configuration.
|
|
701
|
+
*/
|
|
702
|
+
saveFile: (content: string, options?: PluginFsSaveFileOptions) => Promise<string | null>;
|
|
703
|
+
/**
|
|
704
|
+
* Reads a UTF-8 text file from an allowlisted path. Requires the `filesystem:read`
|
|
705
|
+
* permission.
|
|
706
|
+
*
|
|
707
|
+
* @param path - Absolute path on the allowlist.
|
|
708
|
+
*/
|
|
709
|
+
readFile: (path: string) => Promise<string>;
|
|
710
|
+
/**
|
|
711
|
+
* Writes UTF-8 text to an allowlisted path. Requires the `filesystem:write`
|
|
712
|
+
* permission.
|
|
713
|
+
*
|
|
714
|
+
* @param path - Absolute path on the allowlist.
|
|
715
|
+
* @param content - UTF-8 text to write.
|
|
716
|
+
*/
|
|
717
|
+
writeFile: (path: string, content: string) => Promise<void>;
|
|
718
|
+
/**
|
|
719
|
+
* Watches an allowlisted file for changes and invokes the listener when the file
|
|
720
|
+
* is modified. Requires the `filesystem:read` permission. Returns a {@link Disposable}
|
|
721
|
+
* that stops watching when disposed.
|
|
722
|
+
*
|
|
723
|
+
* @param path - Absolute path on the allowlist.
|
|
724
|
+
* @param listener - Called with the normalized path after a debounced change event.
|
|
725
|
+
*/
|
|
726
|
+
watchFile: (path: string, listener: (path: string) => void) => Disposable;
|
|
727
|
+
}
|
|
728
|
+
/**
|
|
729
|
+
* UI contribution registration and feedback APIs available on {@link PluginContext.ui}.
|
|
730
|
+
*
|
|
731
|
+
* All `register*` methods require the `ui` permission, return a {@link Disposable},
|
|
732
|
+
* and require contribution ids that match `manifest.contributes.*` entries.
|
|
733
|
+
* Push every returned disposable onto {@link PluginContext.subscriptions}.
|
|
734
|
+
*/
|
|
735
|
+
export interface PluginUi {
|
|
736
|
+
/**
|
|
737
|
+
* Registers a Settings panel alongside built-in sections (General, Storage, etc.).
|
|
738
|
+
*
|
|
739
|
+
* Manifest: `contributes.settingsSections` — `section.id` must match an entry there.
|
|
740
|
+
*
|
|
741
|
+
* @param section - Settings section contribution.
|
|
742
|
+
* @returns A {@link Disposable} that unregisters the section when disposed.
|
|
743
|
+
*/
|
|
744
|
+
registerSettingsSection(section: SettingsSectionContribution): Disposable;
|
|
745
|
+
/**
|
|
746
|
+
* Registers a switchable left sidebar destination.
|
|
747
|
+
*
|
|
748
|
+
* Manifest: `contributes.sidebarPanels` — `panel.id` must match an entry there.
|
|
749
|
+
*
|
|
750
|
+
* @param panel - Sidebar panel contribution.
|
|
751
|
+
* @returns A {@link Disposable} that unregisters the panel when disposed.
|
|
752
|
+
*/
|
|
753
|
+
registerSidebarPanel(panel: SidebarPanelContribution): Disposable;
|
|
754
|
+
/**
|
|
755
|
+
* Adds a collapsible block inside the scrollable sidebar.
|
|
756
|
+
*
|
|
757
|
+
* Manifest: `contributes.sidebarSections` — `section.id` must match an entry there.
|
|
758
|
+
*
|
|
759
|
+
* @param section - Sidebar section contribution.
|
|
760
|
+
* @returns A {@link Disposable} that unregisters the section when disposed.
|
|
761
|
+
*/
|
|
762
|
+
registerSidebarSection(section: SidebarSectionContribution): Disposable;
|
|
763
|
+
/**
|
|
764
|
+
* Registers a full main-area overlay replacing the request editor while open.
|
|
765
|
+
*
|
|
766
|
+
* Manifest: `contributes.mainViews` — `view.id` must match an entry there.
|
|
767
|
+
*
|
|
768
|
+
* @param view - Main view contribution.
|
|
769
|
+
* @returns A {@link Disposable} that unregisters the view when disposed.
|
|
770
|
+
*/
|
|
771
|
+
registerMainView(view: MainViewContribution): Disposable;
|
|
772
|
+
/**
|
|
773
|
+
* Adds a segmented tab to the request editor.
|
|
774
|
+
*
|
|
775
|
+
* Manifest: `contributes.requestTabs` — `tab.id` must match an entry there.
|
|
776
|
+
*
|
|
777
|
+
* @param tab - Request tab contribution.
|
|
778
|
+
* @returns A {@link Disposable} that unregisters the tab when disposed.
|
|
779
|
+
*/
|
|
780
|
+
registerRequestTab(tab: RequestTabContribution): Disposable;
|
|
781
|
+
/**
|
|
782
|
+
* Adds a tab to the response viewer.
|
|
783
|
+
*
|
|
784
|
+
* Manifest: `contributes.responseTabs` — `tab.id` must match an entry there.
|
|
785
|
+
*
|
|
786
|
+
* @param tab - Response tab contribution.
|
|
787
|
+
* @returns A {@link Disposable} that unregisters the tab when disposed.
|
|
788
|
+
*/
|
|
789
|
+
registerResponseTab(tab: ResponseTabContribution): Disposable;
|
|
790
|
+
/**
|
|
791
|
+
* Adds a segmented tab to Collection Settings.
|
|
792
|
+
*
|
|
793
|
+
* Manifest: `contributes.collectionSettingsTabs` — `tab.id` must match an entry there.
|
|
794
|
+
*
|
|
795
|
+
* @param tab - Collection settings tab contribution.
|
|
796
|
+
* @returns A {@link Disposable} that unregisters the tab when disposed.
|
|
797
|
+
*/
|
|
798
|
+
registerCollectionSettingsTab(tab: CollectionSettingsTabContribution): Disposable;
|
|
799
|
+
/**
|
|
800
|
+
* Registers a slide-up footer panel.
|
|
801
|
+
*
|
|
802
|
+
* Manifest: `contributes.footerPanels` — `panel.id` must match an entry there.
|
|
803
|
+
*
|
|
804
|
+
* @param panel - Footer panel contribution.
|
|
805
|
+
* @returns A {@link Disposable} that unregisters the panel when disposed.
|
|
806
|
+
*/
|
|
807
|
+
registerFooterPanel(panel: FooterPanelContribution): Disposable;
|
|
808
|
+
/**
|
|
809
|
+
* Adds an item to an application menu.
|
|
810
|
+
*
|
|
811
|
+
* Manifest: `contributes.menus` plus a matching `contributes.commands` entry.
|
|
812
|
+
*
|
|
813
|
+
* @param item - Menu item contribution.
|
|
814
|
+
* @returns A {@link Disposable} that unregisters the menu item when disposed.
|
|
815
|
+
*/
|
|
816
|
+
registerMenuItem(item: MenuItemContribution): Disposable;
|
|
817
|
+
/**
|
|
818
|
+
* Adds a button to the request URL bar toolbar.
|
|
819
|
+
*
|
|
820
|
+
* Manifest: `contributes.requestToolbarActions` plus a matching `contributes.commands` entry.
|
|
821
|
+
*
|
|
822
|
+
* @param action - Toolbar action contribution.
|
|
823
|
+
* @returns A {@link Disposable} that unregisters the action when disposed.
|
|
824
|
+
*/
|
|
825
|
+
registerRequestToolbarAction(action: RequestToolbarActionContribution): Disposable;
|
|
826
|
+
/**
|
|
827
|
+
* Adds an action to sidebar row context menus.
|
|
828
|
+
*
|
|
829
|
+
* Manifest: `contributes.contextMenus` plus a matching `contributes.commands` entry.
|
|
830
|
+
*
|
|
831
|
+
* @param item - Context menu item contribution.
|
|
832
|
+
* @returns A {@link Disposable} that unregisters the menu item when disposed.
|
|
833
|
+
*/
|
|
834
|
+
registerContextMenuItem(item: ContextMenuItemContribution): Disposable;
|
|
835
|
+
/**
|
|
836
|
+
* Adds a custom status indicator to the footer bar.
|
|
837
|
+
*
|
|
838
|
+
* Manifest: `contributes.statusBarItems` — `item.id` must match an entry there.
|
|
839
|
+
*
|
|
840
|
+
* @param item - Status bar item contribution.
|
|
841
|
+
* @returns A {@link Disposable} that unregisters the item when disposed.
|
|
842
|
+
*/
|
|
843
|
+
registerStatusBarItem(item: StatusBarItemContribution): Disposable;
|
|
844
|
+
/**
|
|
845
|
+
* Shows a non-blocking toast for success or info feedback.
|
|
846
|
+
*
|
|
847
|
+
* Do not use toasts for errors that require acknowledgment — show those inline
|
|
848
|
+
* in your plugin UI instead.
|
|
849
|
+
*
|
|
850
|
+
* @param message - Text shown in the toast.
|
|
851
|
+
* @param options - Optional display options.
|
|
852
|
+
* @param options.duration - Display duration in milliseconds.
|
|
853
|
+
*/
|
|
854
|
+
showToast(message: string, options?: {
|
|
855
|
+
duration?: number;
|
|
856
|
+
}): void;
|
|
857
|
+
}
|
|
858
|
+
/**
|
|
859
|
+
* Serializable query parameter captured from a sent request.
|
|
860
|
+
*/
|
|
861
|
+
export interface OpenRequestDraftParam {
|
|
862
|
+
/**
|
|
863
|
+
* Query parameter name.
|
|
864
|
+
*/
|
|
865
|
+
key: string;
|
|
866
|
+
/**
|
|
867
|
+
* Query parameter value after variable substitution.
|
|
868
|
+
*/
|
|
869
|
+
value: string;
|
|
870
|
+
}
|
|
871
|
+
/**
|
|
872
|
+
* Serializable request draft payload passed to {@link PluginHost.openRequestDraft}.
|
|
873
|
+
*
|
|
874
|
+
* Opens a new request editor tab seeded with captured send metadata.
|
|
875
|
+
*/
|
|
876
|
+
export interface OpenRequestDraftPayload {
|
|
877
|
+
/**
|
|
878
|
+
* Tab title for the new draft. Defaults to "Recent Request" when omitted.
|
|
879
|
+
*/
|
|
880
|
+
name?: string;
|
|
881
|
+
/**
|
|
882
|
+
* HTTP method (for example `GET`, `POST`).
|
|
883
|
+
*/
|
|
884
|
+
method?: string;
|
|
885
|
+
/**
|
|
886
|
+
* Request URL including scheme, host, path, and query string.
|
|
887
|
+
*/
|
|
888
|
+
url?: string;
|
|
889
|
+
/**
|
|
890
|
+
* Outgoing request headers as a flat key/value map.
|
|
891
|
+
*/
|
|
892
|
+
headers?: Record<string, string>;
|
|
893
|
+
/**
|
|
894
|
+
* Enabled query parameters from the sent request.
|
|
895
|
+
*/
|
|
896
|
+
params?: OpenRequestDraftParam[];
|
|
897
|
+
/**
|
|
898
|
+
* Request body content as a string.
|
|
899
|
+
*/
|
|
900
|
+
body?: string;
|
|
901
|
+
/**
|
|
902
|
+
* Request body encoding. Defaults to `text` when body is non-empty, otherwise `none`.
|
|
903
|
+
*/
|
|
904
|
+
bodyType?: BodyType;
|
|
905
|
+
}
|
|
906
|
+
/**
|
|
907
|
+
* A single saved request to create when bulk-importing a collection from a plugin.
|
|
908
|
+
*/
|
|
909
|
+
export interface CreateCollectionRequest {
|
|
910
|
+
/**
|
|
911
|
+
* Display name for the saved request.
|
|
912
|
+
*/
|
|
913
|
+
name: string;
|
|
914
|
+
/**
|
|
915
|
+
* HTTP method (for example `GET`, `POST`). Defaults to `GET` when omitted or invalid.
|
|
916
|
+
*/
|
|
917
|
+
method?: string;
|
|
918
|
+
/**
|
|
919
|
+
* Request URL including scheme, host, path, and query string.
|
|
920
|
+
*/
|
|
921
|
+
url?: string;
|
|
922
|
+
/**
|
|
923
|
+
* Outgoing request headers as a flat key/value map.
|
|
924
|
+
*/
|
|
925
|
+
headers?: Record<string, string>;
|
|
926
|
+
/**
|
|
927
|
+
* Enabled query parameters for the request.
|
|
928
|
+
*/
|
|
929
|
+
params?: OpenRequestDraftParam[];
|
|
930
|
+
/**
|
|
931
|
+
* Request body content as a string.
|
|
932
|
+
*/
|
|
933
|
+
body?: string;
|
|
934
|
+
/**
|
|
935
|
+
* Request body encoding. Defaults to `text` when body is non-empty, otherwise `none`.
|
|
936
|
+
*/
|
|
937
|
+
bodyType?: BodyType;
|
|
938
|
+
/**
|
|
939
|
+
* Folder name within the new collection. When omitted, the request is created at the collection root.
|
|
940
|
+
*/
|
|
941
|
+
folder?: string;
|
|
942
|
+
/**
|
|
943
|
+
* Free-form notes stored on the saved request.
|
|
944
|
+
*/
|
|
945
|
+
comment?: string;
|
|
946
|
+
}
|
|
947
|
+
/**
|
|
948
|
+
* Payload for {@link PluginHost.createCollection} — bulk-creates a collection with folders and requests.
|
|
949
|
+
*/
|
|
950
|
+
export interface CreateCollectionPayload {
|
|
951
|
+
/**
|
|
952
|
+
* Display name for the new collection.
|
|
953
|
+
*/
|
|
954
|
+
name: string;
|
|
955
|
+
/**
|
|
956
|
+
* Saved requests to create inside the collection.
|
|
957
|
+
*/
|
|
958
|
+
requests: CreateCollectionRequest[];
|
|
959
|
+
}
|
|
960
|
+
/**
|
|
961
|
+
* Result returned after bulk-creating a collection from plugin-provided requests.
|
|
962
|
+
*/
|
|
963
|
+
export interface CreateCollectionResult {
|
|
964
|
+
/**
|
|
965
|
+
* Database id of the new collection.
|
|
966
|
+
*/
|
|
967
|
+
collectionId: number;
|
|
968
|
+
}
|
|
969
|
+
/**
|
|
970
|
+
* Renderer-side HTTP lifecycle events for reacting to completed sends in the UI.
|
|
971
|
+
*
|
|
972
|
+
* Requires the `http` permission. Push returned disposables onto
|
|
973
|
+
* {@link PluginContext.subscriptions}.
|
|
974
|
+
*/
|
|
975
|
+
export interface PluginRendererHttp {
|
|
976
|
+
/**
|
|
977
|
+
* Registers a callback that runs after a request completes in the renderer.
|
|
978
|
+
*
|
|
979
|
+
* Fires for every successful send in the active renderer window — no main entry,
|
|
980
|
+
* custom IPC channel, or polling required.
|
|
981
|
+
*
|
|
982
|
+
* @param handler - Called with the sent request snapshot and response payload.
|
|
983
|
+
* @returns A {@link Disposable} that unregisters the handler when disposed.
|
|
984
|
+
*/
|
|
985
|
+
onAfterSend(handler: (request: PluginHttpRequest, response: PluginHttpResponse) => void | Promise<void>): Disposable;
|
|
986
|
+
}
|
|
987
|
+
/**
|
|
988
|
+
* Renderer-side RPC into the plugin's main entry.
|
|
989
|
+
*
|
|
990
|
+
* Mirrors {@link PluginIpc.handle} on the main side. Requires the `ipc` permission.
|
|
991
|
+
* The host auto-reactivates the main runtime when it has been torn down.
|
|
992
|
+
*/
|
|
993
|
+
export interface PluginIpcInvoker {
|
|
994
|
+
/**
|
|
995
|
+
* Invokes a handler registered with {@link PluginIpc.handle} in the main entry.
|
|
996
|
+
*
|
|
997
|
+
* @param channel - Channel name unique within this plugin.
|
|
998
|
+
* @param args - Arguments forwarded to the main handler.
|
|
999
|
+
* @returns The handler return value.
|
|
1000
|
+
*/
|
|
1001
|
+
invoke<T>(channel: string, ...args: unknown[]): Promise<T>;
|
|
1002
|
+
}
|
|
1003
|
+
/**
|
|
1004
|
+
* Variable row supplied by a plugin when creating or updating an environment.
|
|
1005
|
+
*/
|
|
1006
|
+
export interface PluginVariableInput {
|
|
1007
|
+
/**
|
|
1008
|
+
* Variable name referenced in {{key}} placeholders.
|
|
1009
|
+
*/
|
|
1010
|
+
key: string;
|
|
1011
|
+
/**
|
|
1012
|
+
* Value substituted when the variable is resolved.
|
|
1013
|
+
*/
|
|
1014
|
+
value: string;
|
|
1015
|
+
/**
|
|
1016
|
+
* Fallback value used when value is empty.
|
|
1017
|
+
*/
|
|
1018
|
+
defaultValue?: string;
|
|
1019
|
+
/**
|
|
1020
|
+
* When true, value is included in collection exports.
|
|
1021
|
+
*/
|
|
1022
|
+
share?: boolean;
|
|
1023
|
+
}
|
|
1024
|
+
/**
|
|
1025
|
+
* Result returned after creating an environment from plugin-provided variables.
|
|
1026
|
+
*/
|
|
1027
|
+
export interface CreatedEnvironmentResult {
|
|
1028
|
+
/**
|
|
1029
|
+
* Database id of the new environment.
|
|
1030
|
+
*/
|
|
1031
|
+
id: number;
|
|
1032
|
+
/**
|
|
1033
|
+
* Trimmed display name persisted for the environment.
|
|
1034
|
+
*/
|
|
1035
|
+
name: string;
|
|
1036
|
+
}
|
|
1037
|
+
/**
|
|
1038
|
+
* Typed wrappers for built-in HarborClient request editor commands.
|
|
1039
|
+
*
|
|
1040
|
+
* Requires the `ui` permission. Prefer these over stringly-typed
|
|
1041
|
+
* {@link PluginCommands.execute} for opening request tabs.
|
|
1042
|
+
*/
|
|
1043
|
+
export interface PluginHost {
|
|
1044
|
+
/**
|
|
1045
|
+
* Opens a new request tab seeded with captured send metadata.
|
|
1046
|
+
*
|
|
1047
|
+
* @param payload - Partial draft fields from a recent request entry.
|
|
1048
|
+
*/
|
|
1049
|
+
openRequestDraft(payload: OpenRequestDraftPayload): Promise<void>;
|
|
1050
|
+
/**
|
|
1051
|
+
* Opens a saved collection request or focuses an existing tab for it.
|
|
1052
|
+
*
|
|
1053
|
+
* @param requestId - Saved request database id.
|
|
1054
|
+
*/
|
|
1055
|
+
loadRequest(requestId: number): Promise<void>;
|
|
1056
|
+
/**
|
|
1057
|
+
* Sends the active request editor tab using the same pipeline as the Send button
|
|
1058
|
+
* (pre/post scripts, variable substitution, auth merge, and history).
|
|
1059
|
+
*
|
|
1060
|
+
* No-op when a send is already in flight for the active tab.
|
|
1061
|
+
*/
|
|
1062
|
+
sendRequest(): Promise<void>;
|
|
1063
|
+
/**
|
|
1064
|
+
* Creates a new environment, populates it with variables, and selects it as active.
|
|
1065
|
+
*
|
|
1066
|
+
* @param name - Display name for the new environment.
|
|
1067
|
+
* @param variables - Initial variable rows.
|
|
1068
|
+
*/
|
|
1069
|
+
createEnvironmentWithVariables(name: string, variables: PluginVariableInput[]): Promise<CreatedEnvironmentResult>;
|
|
1070
|
+
/**
|
|
1071
|
+
* Replaces all variables on an existing environment while preserving its name.
|
|
1072
|
+
*
|
|
1073
|
+
* @param environmentId - Target environment database id.
|
|
1074
|
+
* @param variables - Variable rows that fully replace the current list.
|
|
1075
|
+
*/
|
|
1076
|
+
updateEnvironmentVariables(environmentId: number, variables: PluginVariableInput[]): Promise<void>;
|
|
1077
|
+
/**
|
|
1078
|
+
* Creates a new collection populated with folders and saved requests supplied by a plugin.
|
|
1079
|
+
*
|
|
1080
|
+
* Requests with the same {@link CreateCollectionRequest.folder} value are grouped into one folder.
|
|
1081
|
+
* Requests without a folder are created at the collection root.
|
|
1082
|
+
*
|
|
1083
|
+
* @param payload - Collection name and request rows to persist.
|
|
1084
|
+
* @returns The database id of the created collection.
|
|
1085
|
+
*/
|
|
1086
|
+
createCollection(payload: CreateCollectionPayload): Promise<CreateCollectionResult>;
|
|
1087
|
+
}
|
|
1088
|
+
/**
|
|
1089
|
+
* The plugin API surface passed as `hc` to your renderer entry's `activate(hc)` function.
|
|
1090
|
+
*
|
|
1091
|
+
* Export `activate(hc: PluginContext)` and optionally `deactivate()` from your renderer
|
|
1092
|
+
* bundle. Use {@link PluginContext.react} for hooks and JSX — do not import or bundle
|
|
1093
|
+
* `react` / `react-dom` in your plugin bundle.
|
|
1094
|
+
*/
|
|
1095
|
+
export interface PluginContext {
|
|
1096
|
+
/**
|
|
1097
|
+
* Plugin manifest id from `manifest.json`.
|
|
1098
|
+
*
|
|
1099
|
+
* Use for IPC routing and logging instead of hardcoding the manifest id in plugin code.
|
|
1100
|
+
*/
|
|
1101
|
+
pluginId: string;
|
|
1102
|
+
/**
|
|
1103
|
+
* The same React instance HarborClient uses in the renderer.
|
|
1104
|
+
*
|
|
1105
|
+
* Use for `useState`, `useEffect`, and JSX. Do not bundle React in your plugin.
|
|
1106
|
+
*/
|
|
1107
|
+
react: typeof React;
|
|
1108
|
+
/**
|
|
1109
|
+
* UI contribution registration and toast APIs. Requires the `ui` permission.
|
|
1110
|
+
*/
|
|
1111
|
+
ui: PluginUi;
|
|
1112
|
+
/**
|
|
1113
|
+
* Custom appearance theme registration and change notifications. Requires the `ui` permission.
|
|
1114
|
+
*/
|
|
1115
|
+
themes: PluginThemes;
|
|
1116
|
+
/**
|
|
1117
|
+
* Command registration and execution. Requires the `ui` permission.
|
|
1118
|
+
*/
|
|
1119
|
+
commands: PluginCommands;
|
|
1120
|
+
/**
|
|
1121
|
+
* Plugin-scoped persistent storage. Requires the `storage` permission.
|
|
1122
|
+
*/
|
|
1123
|
+
storage: PluginStorage;
|
|
1124
|
+
/**
|
|
1125
|
+
* Plugin-scoped filesystem access. Requires `filesystem:*` permissions as documented
|
|
1126
|
+
* on each method.
|
|
1127
|
+
*/
|
|
1128
|
+
fs: PluginFs;
|
|
1129
|
+
/**
|
|
1130
|
+
* Renderer-side HTTP lifecycle events. Requires the `http` permission.
|
|
1131
|
+
*/
|
|
1132
|
+
http: PluginRendererHttp;
|
|
1133
|
+
/**
|
|
1134
|
+
* Renderer-side RPC into the plugin main entry. Requires the `ipc` permission.
|
|
1135
|
+
*/
|
|
1136
|
+
ipc: PluginIpcInvoker;
|
|
1137
|
+
/**
|
|
1138
|
+
* Typed wrappers for built-in request editor commands. Requires the `ui` permission.
|
|
1139
|
+
*/
|
|
1140
|
+
host: PluginHost;
|
|
1141
|
+
/**
|
|
1142
|
+
* Disposables to clean up on deactivation.
|
|
1143
|
+
*
|
|
1144
|
+
* Push every disposable returned by registration APIs here. The host disposes all
|
|
1145
|
+
* entries when the plugin deactivates.
|
|
1146
|
+
*/
|
|
1147
|
+
subscriptions: Disposable[];
|
|
1148
|
+
}
|
|
1149
|
+
/**
|
|
1150
|
+
* Serialized HTTP request passed to main-process before-send hooks.
|
|
1151
|
+
*
|
|
1152
|
+
* Handlers may mutate this object to change method, URL, headers, or body before
|
|
1153
|
+
* the request is sent.
|
|
1154
|
+
*/
|
|
1155
|
+
export interface PluginHttpRequest {
|
|
1156
|
+
/**
|
|
1157
|
+
* HTTP method (for example `GET`, `POST`).
|
|
1158
|
+
*/
|
|
1159
|
+
method: string;
|
|
1160
|
+
/**
|
|
1161
|
+
* Request URL including scheme, host, path, and query string.
|
|
1162
|
+
*/
|
|
1163
|
+
url: string;
|
|
1164
|
+
/**
|
|
1165
|
+
* Outgoing request headers as a flat key/value map.
|
|
1166
|
+
*/
|
|
1167
|
+
headers: Record<string, string>;
|
|
1168
|
+
/**
|
|
1169
|
+
* Request body content as a string.
|
|
1170
|
+
*/
|
|
1171
|
+
body: string;
|
|
1172
|
+
/**
|
|
1173
|
+
* Request body content type when captured from the send pipeline.
|
|
1174
|
+
*/
|
|
1175
|
+
bodyType?: string;
|
|
1176
|
+
/**
|
|
1177
|
+
* Enabled query parameters from the outgoing request.
|
|
1178
|
+
*/
|
|
1179
|
+
params?: Array<{
|
|
1180
|
+
key: string;
|
|
1181
|
+
value: string;
|
|
1182
|
+
}>;
|
|
1183
|
+
/**
|
|
1184
|
+
* Saved collection request id when the send originated from a saved request tab.
|
|
1185
|
+
*/
|
|
1186
|
+
sourceRequestId?: number;
|
|
1187
|
+
/**
|
|
1188
|
+
* Display name from the request tab when {@link sourceRequestId} is set.
|
|
1189
|
+
*/
|
|
1190
|
+
sourceRequestName?: string;
|
|
1191
|
+
}
|
|
1192
|
+
/**
|
|
1193
|
+
* Serialized HTTP response passed to main-process after-send hooks.
|
|
1194
|
+
*/
|
|
1195
|
+
export interface PluginHttpResponse {
|
|
1196
|
+
/**
|
|
1197
|
+
* HTTP status code (for example `200`, `404`).
|
|
1198
|
+
*/
|
|
1199
|
+
status: number;
|
|
1200
|
+
/**
|
|
1201
|
+
* HTTP status text (for example `OK`, `Not Found`).
|
|
1202
|
+
*/
|
|
1203
|
+
statusText: string;
|
|
1204
|
+
/**
|
|
1205
|
+
* Response headers as a flat key/value map.
|
|
1206
|
+
*/
|
|
1207
|
+
headers: Record<string, string>;
|
|
1208
|
+
/**
|
|
1209
|
+
* Response body content as a string.
|
|
1210
|
+
*/
|
|
1211
|
+
body: string;
|
|
1212
|
+
}
|
|
1213
|
+
/**
|
|
1214
|
+
* HTTP hook registration API available on {@link MainPluginContext.http}.
|
|
1215
|
+
*
|
|
1216
|
+
* Requires the `http` permission. Push returned disposables onto
|
|
1217
|
+
* {@link MainPluginContext.subscriptions}.
|
|
1218
|
+
*/
|
|
1219
|
+
export interface PluginHttp {
|
|
1220
|
+
/**
|
|
1221
|
+
* Registers a callback that runs before each outgoing HTTP request.
|
|
1222
|
+
*
|
|
1223
|
+
* Mutate the request object to change method, URL, headers, or body.
|
|
1224
|
+
*
|
|
1225
|
+
* @param handler - Called with the mutable request snapshot.
|
|
1226
|
+
* @returns A {@link Disposable} that unregisters the handler when disposed.
|
|
1227
|
+
*/
|
|
1228
|
+
onBeforeSend(handler: (request: PluginHttpRequest) => void | Promise<void>): Disposable;
|
|
1229
|
+
/**
|
|
1230
|
+
* Registers a callback that runs after the response is received.
|
|
1231
|
+
*
|
|
1232
|
+
* @param handler - Called with the request that was sent and the response payload.
|
|
1233
|
+
* @returns A {@link Disposable} that unregisters the handler when disposed.
|
|
1234
|
+
*/
|
|
1235
|
+
onAfterSend(handler: (request: PluginHttpRequest, response: PluginHttpResponse) => void | Promise<void>): Disposable;
|
|
1236
|
+
}
|
|
1237
|
+
/**
|
|
1238
|
+
* Custom IPC registration API available on {@link MainPluginContext.ipc}.
|
|
1239
|
+
*
|
|
1240
|
+
* Exposes RPC channels callable from the renderer half of the same plugin.
|
|
1241
|
+
* Requires the `ipc` permission. Push returned disposables onto
|
|
1242
|
+
* {@link MainPluginContext.subscriptions}.
|
|
1243
|
+
*/
|
|
1244
|
+
export interface PluginIpc {
|
|
1245
|
+
/**
|
|
1246
|
+
* Registers a handler for a plugin-scoped IPC channel.
|
|
1247
|
+
*
|
|
1248
|
+
* @param channel - Channel name unique within this plugin.
|
|
1249
|
+
* @param handler - Called when the renderer invokes this channel.
|
|
1250
|
+
* @returns A {@link Disposable} that unregisters the handler when disposed.
|
|
1251
|
+
*/
|
|
1252
|
+
handle(channel: string, handler: (...args: unknown[]) => unknown): Disposable;
|
|
1253
|
+
}
|
|
1254
|
+
/**
|
|
1255
|
+
* The plugin API surface passed as `hc` to your main entry's `activate(hc)` function.
|
|
1256
|
+
*
|
|
1257
|
+
* Main entries run inside the SES-hardened utilityProcess — not in the renderer.
|
|
1258
|
+
* Use this entry for HTTP hooks and custom IPC, not for React UI. Export
|
|
1259
|
+
* `activate(hc: MainPluginContext)` and optionally `deactivate()` from your main bundle.
|
|
1260
|
+
*/
|
|
1261
|
+
export interface MainPluginContext {
|
|
1262
|
+
/**
|
|
1263
|
+
* Disposables to clean up on deactivation.
|
|
1264
|
+
*
|
|
1265
|
+
* Push every disposable returned by registration APIs here. The host disposes all
|
|
1266
|
+
* entries when the plugin deactivates.
|
|
1267
|
+
*/
|
|
1268
|
+
subscriptions: Disposable[];
|
|
1269
|
+
/**
|
|
1270
|
+
* Plugin-scoped persistent storage. Requires the `storage` permission.
|
|
1271
|
+
*/
|
|
1272
|
+
storage: PluginStorage;
|
|
1273
|
+
/**
|
|
1274
|
+
* HTTP hook registration. Requires the `http` permission.
|
|
1275
|
+
*/
|
|
1276
|
+
http: PluginHttp;
|
|
1277
|
+
/**
|
|
1278
|
+
* Custom IPC handler registration. Requires the `ipc` permission.
|
|
1279
|
+
*/
|
|
1280
|
+
ipc: PluginIpc;
|
|
1281
|
+
}
|
|
1282
|
+
//# sourceMappingURL=types.d.ts.map
|