@caido/sdk-frontend 0.49.1-beta.3 → 0.49.1-beta.5

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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@caido/sdk-frontend",
3
- "version": "0.49.1-beta.3",
3
+ "version": "0.49.1-beta.5",
4
4
  "description": "Typing for the Caido Frontend SDK",
5
5
  "author": "Caido Labs Inc. <dev@caido.io>",
6
6
  "license": "MIT",
@@ -1,11 +1,11 @@
1
- export { FooterSlot } from "./types/footer";
1
+ export { FooterSlot, type FooterSlotContent } from "./types/footer";
2
2
  export type { DialogOptions } from "./types/window";
3
3
  export type { CommandContext } from "./types/commands";
4
4
  export type { MenuItem } from "./types/menu";
5
- export { type ReplayTab, type ReplaySession, type ReplayCollection, ReplaySlot, } from "./types/replay";
5
+ export { type ReplayTab, type ReplaySession, type ReplayCollection, ReplaySlot, type ReplaySlotContent, } from "./types/replay";
6
6
  export type { HostedFile } from "./types/files";
7
7
  export type { Filter } from "./types/filter";
8
- export type { HTTPQL, ID } from "./types/utils";
8
+ export type { HTTPQL, ID, ComponentDefinition } from "./types/utils";
9
9
  export type { JSONValue, JSONCompatible } from "./types/json";
10
10
  export type { SlotContent, ButtonSlotContent, CustomSlotContent, CommandSlotContent, } from "./types/slots";
11
11
  export type { RequestViewModeOptions } from "./types/request";
@@ -6,7 +6,6 @@ import { type CommandID } from "../types/commands";
6
6
  export type CommandPaletteSDK = {
7
7
  /**
8
8
  * Register a command.
9
- * @deprecated Use `sdk.commandPalette.addToSlot` instead.
10
9
  * @param commandId The id of the command to register.
11
10
  */
12
11
  register: (commandId: CommandID) => void;
@@ -1,6 +1,6 @@
1
1
  import { type Extension } from "@codemirror/state";
2
- import { type ReplayCollection, type ReplaySession, type ReplaySlot, type ReplayTab } from "../types/replay";
3
- import { type ButtonSlotContent, type CommandSlotContent, type CustomSlotContent, type DefineAddToSlotFn } from "../types/slots";
2
+ import { type ReplayCollection, type ReplaySession, type ReplaySlotContent, type ReplayTab } from "../types/replay";
3
+ import { type DefineAddToSlotFn } from "../types/slots";
4
4
  import type { ID } from "../types/utils";
5
5
  /**
6
6
  * Utilities to interact with Replay.
@@ -96,11 +96,7 @@ export type ReplaySDK = {
96
96
  * });
97
97
  * ```
98
98
  */
99
- addToSlot: DefineAddToSlotFn<{
100
- [ReplaySlot.SessionToolbarPrimary]: ButtonSlotContent | CustomSlotContent | CommandSlotContent;
101
- [ReplaySlot.SessionToolbarSecondary]: ButtonSlotContent | CustomSlotContent | CommandSlotContent;
102
- [ReplaySlot.Topbar]: ButtonSlotContent | CustomSlotContent | CommandSlotContent;
103
- }>;
99
+ addToSlot: DefineAddToSlotFn<ReplaySlotContent>;
104
100
  /**
105
101
  * Add an extension to the request editor.
106
102
  * @param extension The extension to add.
@@ -1,6 +1,6 @@
1
1
  import type { Editor } from "../types/editor";
2
- import type { CustomSlotContent } from "../types/slots";
3
- import { type DialogOptions } from "../types/window";
2
+ import type { ComponentDefinition } from "../types/utils";
3
+ import { type Dialog, type DialogOptions } from "../types/window";
4
4
  /**
5
5
  * Utilities to interact with the active page.
6
6
  * @category Window
@@ -32,6 +32,7 @@ export type WindowSDK = {
32
32
  * @param options.modal Whether the dialog is modal. Defaults to true
33
33
  * @param options.position The position of the dialog on the screen. Defaults to center
34
34
  * @param options.closable Whether the close icon is hidden . Defaults to false
35
+ * @returns A dialog object that can be used to close the dialog.
35
36
  */
36
- showDialog: (component: CustomSlotContent, options?: DialogOptions) => void;
37
+ showDialog: (component: ComponentDefinition, options?: DialogOptions) => Dialog;
37
38
  };
@@ -1,3 +1,4 @@
1
+ import { type ButtonSlotContent, type CommandSlotContent, type CustomSlotContent } from "./slots";
1
2
  import { type ID } from "./utils";
2
3
  export declare const ReplaySlot: {
3
4
  readonly SessionToolbarPrimary: "session-toolbar-primary";
@@ -5,6 +6,11 @@ export declare const ReplaySlot: {
5
6
  readonly Topbar: "topbar";
6
7
  };
7
8
  export type ReplaySlot = (typeof ReplaySlot)[keyof typeof ReplaySlot];
9
+ export type ReplaySlotContent = {
10
+ [ReplaySlot.SessionToolbarPrimary]: ButtonSlotContent | CustomSlotContent | CommandSlotContent;
11
+ [ReplaySlot.SessionToolbarSecondary]: ButtonSlotContent | CustomSlotContent | CommandSlotContent;
12
+ [ReplaySlot.Topbar]: ButtonSlotContent | CustomSlotContent | CommandSlotContent;
13
+ };
8
14
  /**
9
15
  * A replay tab.
10
16
  * @category Replay
@@ -1,4 +1,4 @@
1
- import { type Component } from "vue";
1
+ import { type ComponentDefinition } from "./utils";
2
2
  export type RequestViewModeOptions = {
3
3
  /**
4
4
  * The label of the view mode.
@@ -7,5 +7,5 @@ export type RequestViewModeOptions = {
7
7
  /**
8
8
  * The component to render when the view mode is selected.
9
9
  */
10
- component: Component;
10
+ view: ComponentDefinition;
11
11
  };
@@ -1,5 +1,5 @@
1
- import { type Component } from "vue";
2
1
  import { type CommandID } from "./commands";
2
+ import { type ComponentDefinition } from "./utils";
3
3
  type DefineSlotContent<TType extends string, P extends Record<string, unknown>> = {
4
4
  type: TType;
5
5
  } & P;
@@ -8,8 +8,8 @@ export type ButtonSlotContent = DefineSlotContent<"Button", {
8
8
  icon?: string;
9
9
  onClick: () => void;
10
10
  }>;
11
- export type CustomSlotContent<TProps extends Record<string, unknown> = Record<string, unknown>> = DefineSlotContent<"Custom", {
12
- component: Component<TProps>;
11
+ export type CustomSlotContent = DefineSlotContent<"Custom", {
12
+ definition: ComponentDefinition;
13
13
  }>;
14
14
  export type CommandSlotContent = DefineSlotContent<"Command", {
15
15
  commandId: CommandID;
@@ -1,3 +1,4 @@
1
+ import { type Component as VueComponent } from "vue";
1
2
  /**
2
3
  * A unique Caido identifier per type.
3
4
  */
@@ -18,6 +19,15 @@ export type HTTPQL = string & {
18
19
  export type Icon = string & {
19
20
  __icon?: never;
20
21
  };
22
+ /**
23
+ * A custom component that will be rendered in the UI.
24
+ *
25
+ */
26
+ export type ComponentDefinition = {
27
+ component: VueComponent;
28
+ props?: Record<string, unknown>;
29
+ events?: Record<string, (...args: unknown[]) => void>;
30
+ };
21
31
  export type PromisifiedReturnType<T extends (...args: unknown[]) => unknown> = ReturnType<T> extends Promise<infer U> ? Promise<U> : Promise<ReturnType<T>>;
22
32
  /**
23
33
  * A handle for a listener.
@@ -6,3 +6,6 @@ export type DialogOptions = {
6
6
  modal?: boolean;
7
7
  position?: "left" | "right" | "top" | "bottom" | "center" | "topleft" | "topright" | "bottomleft" | "bottomright";
8
8
  };
9
+ export type Dialog = {
10
+ close: () => void;
11
+ };