@caido/sdk-frontend 0.48.2-beta.0 → 0.48.2-beta.10

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.
@@ -5,6 +5,7 @@
5
5
  export type CommandPaletteSDK = {
6
6
  /**
7
7
  * Register a command.
8
+ * @deprecated Use `sdk.commandPalette.addToSlot` instead.
8
9
  * @param commandId The id of the command to register.
9
10
  */
10
11
  register: (commandId: string) => void;
@@ -23,12 +23,14 @@ import type { StorageSDK } from "./storage";
23
23
  import type { UISDK } from "./ui";
24
24
  import type { WindowSDK } from "./window";
25
25
  import type { WorkflowSDK } from "./workflows";
26
+ export type { DialogOptions } from "./window";
26
27
  export type { CommandContext } from "./commands";
27
28
  export type { MenuItem } from "./menu";
28
- export type { ReplayTab, ReplaySession, ReplayCollection } from "./replay";
29
+ export { type ReplayTab, type ReplaySession, type ReplayCollection, ReplaySlot, } from "./replay";
29
30
  export type { HostedFile } from "./files";
30
31
  export type { Filter } from "./filters";
31
32
  export type { HTTPQL, ID, JSONValue, JSONCompatible } from "./utils";
33
+ export type { SlotContent, ButtonSlotContent, CustomSlotContent, CommandSlotContent, } from "./slots";
32
34
  export type { MatchReplaceRule, MatchReplaceCollection, MatchReplaceSection, MatchReplaceSectionRequestBody, MatchReplaceSectionRequestFirstLine, MatchReplaceSectionRequestHeader, MatchReplaceSectionRequestMethod, MatchReplaceSectionRequestPath, MatchReplaceSectionRequestQuery, MatchReplaceSectionResponseBody, MatchReplaceSectionResponseFirstLine, MatchReplaceSectionResponseHeader, MatchReplaceSectionResponseStatusCode, MatchReplaceOperationStatusCode, MatchReplaceOperationStatusCodeUpdate, MatchReplaceOperationQuery, MatchReplaceOperationQueryRaw, MatchReplaceOperationQueryAdd, MatchReplaceOperationQueryRemove, MatchReplaceOperationQueryUpdate, MatchReplaceOperationPath, MatchReplaceOperationPathRaw, MatchReplaceOperationMethod, MatchReplaceOperationMethodUpdate, MatchReplaceOperationHeader, MatchReplaceOperationHeaderRaw, MatchReplaceOperationHeaderAdd, MatchReplaceOperationHeaderRemove, MatchReplaceOperationHeaderUpdate, MatchReplaceOperationBody, MatchReplaceOperationBodyRaw, MatchReplaceOperationFirstLine, MatchReplaceOperationFirstLineRaw, MatchReplaceReplacer, MatchReplaceReplacerTerm, MatchReplaceReplacerWorkflow, MatchReplaceMatcherName, MatchReplaceMatcherRaw, MatchReplaceMatcherRawFull, MatchReplaceMatcherRawRegex, MatchReplaceMatcherRawValue, } from "./matchReplace";
33
35
  export type { Scope } from "./scopes";
34
36
  export type { EnvironmentVariable } from "./environment";
@@ -1,4 +1,12 @@
1
+ import { type Extension } from "@codemirror/state";
2
+ import { type ButtonSlotContent, type CommandSlotContent, type CustomSlotContent, type DefineAddToSlotFn } from "./slots";
1
3
  import type { ID } from "./utils";
4
+ export declare const ReplaySlot: {
5
+ readonly SessionToolbarPrimary: "session-toolbar-primary";
6
+ readonly SessionToolbarSecondary: "session-toolbar-secondary";
7
+ readonly Topbar: "topbar";
8
+ };
9
+ export type ReplaySlot = (typeof ReplaySlot)[keyof typeof ReplaySlot];
2
10
  /**
3
11
  * A replay tab.
4
12
  * @category Replay
@@ -112,4 +120,41 @@ export type ReplaySDK = {
112
120
  * @returns Whether the collection was deleted.
113
121
  */
114
122
  deleteCollection: (id: ID) => Promise<boolean>;
123
+ /**
124
+ * Add a component to a slot.
125
+ * @param slot The slot to add the component to.
126
+ * @param content The content to add to the slot.
127
+ * @example
128
+ * ```ts
129
+ * addToSlot(ReplaySlot.SessionToolbarPrimary, {
130
+ * kind: "Command",
131
+ * commandId: "my-command",
132
+ * icon: "my-icon",
133
+ * });
134
+ *
135
+ * addToSlot(ReplaySlot.SessionToolbarSecondary, {
136
+ * kind: "Custom",
137
+ * component: MyComponent,
138
+ * });
139
+ *
140
+ * addToSlot(ReplaySlot.Topbar, {
141
+ * kind: "Button",
142
+ * label: "My Button",
143
+ * icon: "my-icon",
144
+ * onClick: () => {
145
+ * console.log("Button clicked");
146
+ * },
147
+ * });
148
+ * ```
149
+ */
150
+ addToSlot: DefineAddToSlotFn<{
151
+ [ReplaySlot.SessionToolbarPrimary]: ButtonSlotContent | CustomSlotContent | CommandSlotContent;
152
+ [ReplaySlot.SessionToolbarSecondary]: ButtonSlotContent | CustomSlotContent | CommandSlotContent;
153
+ [ReplaySlot.Topbar]: ButtonSlotContent | CustomSlotContent | CommandSlotContent;
154
+ }>;
155
+ /**
156
+ * Add an extension to the request editor.
157
+ * @param extension The extension to add.
158
+ */
159
+ addRequestEditorExtension: (extension: Extension) => void;
115
160
  };
@@ -0,0 +1,22 @@
1
+ import { type Component } from "vue";
2
+ import { type CommandID } from "./utils";
3
+ type DefineSlotContent<TType extends string, P extends Record<string, unknown>> = {
4
+ type: TType;
5
+ } & P;
6
+ export type ButtonSlotContent = DefineSlotContent<"Button", {
7
+ label: string;
8
+ icon?: string;
9
+ onClick: () => void;
10
+ }>;
11
+ export type CustomSlotContent<TProps extends Record<string, unknown> = Record<string, unknown>> = DefineSlotContent<"Custom", {
12
+ component: Component<TProps>;
13
+ }>;
14
+ export type CommandSlotContent = DefineSlotContent<"Command", {
15
+ commandId: CommandID;
16
+ icon?: string;
17
+ }>;
18
+ export type SlotContent = ButtonSlotContent | CustomSlotContent | CommandSlotContent;
19
+ export type DefineAddToSlotFn<TMap extends Record<string, DefineSlotContent<string, Record<string, unknown>>>> = {
20
+ <K extends keyof TMap>(slot: K, spec: TMap[K]): void;
21
+ };
22
+ export {};
@@ -1,4 +1,5 @@
1
1
  import type { Editor } from "./editor";
2
+ import type { CustomSlotContent } from "./slots";
2
3
  /**
3
4
  * Utilities to interact with the active page.
4
5
  * @category Window
@@ -20,4 +21,24 @@ export type WindowSDK = {
20
21
  variant?: "success" | "error" | "warning" | "info";
21
22
  duration?: number;
22
23
  }) => void;
24
+ /**
25
+ * Show a dialog component.
26
+ * @param component The custom slot content to display in the dialog.
27
+ * @param options Options for the dialog.
28
+ * @param options.title The title text for the dialog. Defaults to ""
29
+ * @param options.draggable Whether the dialog is draggable. Defaults to false
30
+ * @param options.closeOnEscape Whether the dialog closes when pressing Escape. Defaults to true
31
+ * @param options.modal Whether the dialog is modal. Defaults to true
32
+ * @param options.position The position of the dialog on the screen. Defaults to center
33
+ * @param options.closable Whether the close icon is hidden . Defaults to false
34
+ */
35
+ showDialog: (component: CustomSlotContent, options?: DialogOptions) => void;
36
+ };
37
+ export type DialogOptions = {
38
+ title?: string;
39
+ draggable?: boolean;
40
+ closeOnEscape?: boolean;
41
+ closable?: boolean;
42
+ modal?: boolean;
43
+ position?: "left" | "right" | "top" | "bottom" | "center" | "topleft" | "topright" | "bottomleft" | "bottomright";
23
44
  };