@caido/sdk-frontend 0.56.1-beta.5 → 0.56.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.
@@ -1,5 +1,4 @@
1
- import { type EditorView } from "@codemirror/view";
2
- import { type As, type ComponentDefinition, type ComponentPropsWithSdk, type ID, type Prettify } from "./utils";
1
+ import { type As, type ComponentDefinition, type ID, type Prettify } from "./utils";
3
2
  /**
4
3
  * A draft request that has not yet been saved to the database.
5
4
  * @category Request
@@ -39,43 +38,11 @@ export type RequestFull = Prettify<As<"RequestFull"> & {
39
38
  streamId: ID | undefined;
40
39
  raw: string;
41
40
  }>;
42
- /**
43
- * The internal props for the request read-only view mode.
44
- * @category Request
45
- */
46
- export type RequestReadableViewModePropsInternal = {
47
- request: RequestFull;
48
- view: EditorView;
49
- };
50
- /**
51
- * The internal props for the request writable view mode.
52
- * @category Request
53
- */
54
- export type RequestWritableViewModePropsInternal = {
55
- request: RequestFull | undefined;
56
- draft: RequestDraft;
57
- view: EditorView;
58
- };
59
- /**
60
- * The props for the request writable view mode.
61
- * @category Request
62
- */
63
- export type RequestWritableViewModeProps = ComponentPropsWithSdk<RequestWritableViewModePropsInternal>;
64
- /**
65
- * The props for the request read-only view mode.
66
- * @category Request
67
- */
68
- export type RequestReadableViewModeProps = ComponentPropsWithSdk<RequestReadableViewModePropsInternal>;
69
- /**
70
- * The props group for the request view mode.
71
- * @category Request
72
- */
73
- export type RequestViewModeProps = RequestReadableViewModeProps | RequestWritableViewModeProps | RequestReadableViewModePropsInternal | RequestWritableViewModePropsInternal;
74
41
  /**
75
42
  * Options for defining a custom request view mode.
76
43
  * @category Request
77
44
  */
78
- export type RequestViewModeOptions<TProps extends RequestViewModeProps> = {
45
+ export type RequestViewModeOptions = {
79
46
  /**
80
47
  * The label of the view mode.
81
48
  */
@@ -83,7 +50,7 @@ export type RequestViewModeOptions<TProps extends RequestViewModeProps> = {
83
50
  /**
84
51
  * The component to render when the view mode is selected.
85
52
  */
86
- view: ComponentDefinition<TProps>;
53
+ view: ComponentDefinition;
87
54
  /**
88
55
  * A function that determines if the view mode should be shown for a given request.
89
56
  */
@@ -1,6 +1,5 @@
1
- import { type EditorView } from "@codemirror/view";
2
1
  import type { RequestFull, RequestMeta } from "./request";
3
- import type { As, ComponentDefinition, ComponentPropsWithSdk, ID, Prettify } from "./utils";
2
+ import type { As, ComponentDefinition, ID, Prettify } from "./utils";
4
3
  /**
5
4
  * A complete response with all metadata and raw content.
6
5
  * @category Response
@@ -13,24 +12,11 @@ export type ResponseFull = Prettify<As<"ResponseFull"> & {
13
12
  length: number;
14
13
  createdAt: Date;
15
14
  }>;
16
- /**
17
- * The internal props for the response view mode.
18
- * @category Response
19
- */
20
- export type ResponseViewModePropsInternal = {
21
- response: ResponseFull;
22
- view: EditorView;
23
- };
24
- /**
25
- * The props for the response view mode.
26
- * @category Response
27
- */
28
- export type ResponseViewModeProps = ComponentPropsWithSdk<ResponseViewModePropsInternal>;
29
15
  /**
30
16
  * Options for defining a custom response view mode.
31
17
  * @category Response
32
18
  */
33
- export type ResponseViewModeOptions<TProps extends ResponseViewModeProps | ResponseViewModePropsInternal> = {
19
+ export type ResponseViewModeOptions = {
34
20
  /**
35
21
  * The label of the view mode.
36
22
  */
@@ -38,7 +24,7 @@ export type ResponseViewModeOptions<TProps extends ResponseViewModeProps | Respo
38
24
  /**
39
25
  * The component to render when the view mode is selected.
40
26
  */
41
- view: ComponentDefinition<TProps>;
27
+ view: ComponentDefinition;
42
28
  /**
43
29
  * A function that determines if the view mode should be shown for a given response.
44
30
  */
@@ -1,4 +1,4 @@
1
- import { type ButtonSlotContent, type CommandSlotContent, type CustomSlotContent, type SlotContentProps, type SlotContentPropsGroup } from "./slots";
1
+ import { type ButtonSlotContent, type CommandSlotContent, type CustomSlotContent } from "./slots";
2
2
  import { type ID, type Selection } from "./utils";
3
3
  /**
4
4
  * Represents a scope.
@@ -37,12 +37,9 @@ export declare const ScopeSlot: {
37
37
  readonly CreateHeader: "create-header";
38
38
  };
39
39
  export type ScopeSlot = (typeof ScopeSlot)[keyof typeof ScopeSlot];
40
- /**
41
- * Content that can be added to scope slots.
42
- * @category Scopes
43
- */
44
- export type ScopeSlotContent<TProps extends SlotContentPropsGroup = SlotContentProps> = {
45
- [K in ScopeSlot]: ButtonSlotContent | CustomSlotContent<TProps> | CommandSlotContent;
40
+ export type ScopeSlotContent = {
41
+ [ScopeSlot.UpdateHeader]: ButtonSlotContent | CustomSlotContent | CommandSlotContent;
42
+ [ScopeSlot.CreateHeader]: ButtonSlotContent | CustomSlotContent | CommandSlotContent;
46
43
  };
47
44
  /**
48
45
  * Event fired when the current scope changes.
@@ -1,4 +1,4 @@
1
- import { type ButtonSlotContent, type CommandSlotContent, type CustomSlotContent, type SlotContentProps, type SlotContentPropsGroup } from "./slots";
1
+ import { type ButtonSlotContent, type CommandSlotContent, type CustomSlotContent } from "./slots";
2
2
  /**
3
3
  * The slots in the Search UI.
4
4
  * @category Search
@@ -10,12 +10,8 @@ export declare const SearchSlot: {
10
10
  readonly ToolbarPrimary: "search-toolbar-primary";
11
11
  };
12
12
  export type SearchSlot = (typeof SearchSlot)[keyof typeof SearchSlot];
13
- /**
14
- * Content that can be added to search slots.
15
- * @category Search
16
- */
17
- export type SearchSlotContent<TProps extends SlotContentPropsGroup = SlotContentProps> = {
18
- [K in SearchSlot]: ButtonSlotContent | CustomSlotContent<TProps> | CommandSlotContent;
13
+ export type SearchSlotContent = {
14
+ [SearchSlot.ToolbarPrimary]: ButtonSlotContent | CustomSlotContent | CommandSlotContent;
19
15
  };
20
16
  /**
21
17
  * Search page context.
@@ -1,23 +1,8 @@
1
1
  import { type CommandID } from "./commands";
2
- import { type ComponentDefinition, type ComponentPropsWithSdk, type Prettify } from "./utils";
2
+ import { type ComponentDefinition, type Prettify } from "./utils";
3
3
  type DefineSlotContent<TType extends string, P extends Record<string, unknown>> = Prettify<{
4
4
  type: TType;
5
5
  } & P>;
6
- /**
7
- * The internal props for a slot content.
8
- * @category Slots
9
- */
10
- export type SlotContentPropsInternal = {};
11
- /**
12
- * The props for a slot content.
13
- * @category Slots
14
- */
15
- export type SlotContentProps = ComponentPropsWithSdk<SlotContentPropsInternal>;
16
- /**
17
- * The props group for a slot content.
18
- * @category Slots
19
- */
20
- export type SlotContentPropsGroup = SlotContentProps | SlotContentPropsInternal;
21
6
  /**
22
7
  * Content for a button slot.
23
8
  * @category Slots
@@ -31,8 +16,8 @@ export type ButtonSlotContent = DefineSlotContent<"Button", {
31
16
  * Content for a custom component slot.
32
17
  * @category Slots
33
18
  */
34
- export type CustomSlotContent<TProps extends SlotContentPropsGroup = SlotContentProps> = DefineSlotContent<"Custom", {
35
- definition: ComponentDefinition<TProps>;
19
+ export type CustomSlotContent = DefineSlotContent<"Custom", {
20
+ definition: ComponentDefinition;
36
21
  }>;
37
22
  /**
38
23
  * Content for a command slot.
@@ -46,7 +31,7 @@ export type CommandSlotContent = DefineSlotContent<"Command", {
46
31
  * Union type of all possible slot content types.
47
32
  * @category Slots
48
33
  */
49
- export type SlotContent<TProps extends SlotContentPropsGroup = SlotContentProps> = ButtonSlotContent | CustomSlotContent<TProps> | CommandSlotContent;
34
+ export type SlotContent = ButtonSlotContent | CustomSlotContent | CommandSlotContent;
50
35
  /**
51
36
  * A function type for adding content to slots.
52
37
  * @category Slots
@@ -1,5 +1,4 @@
1
1
  import { type Component as VueComponent } from "vue";
2
- import { type API } from "../index";
3
2
  /**
4
3
  * A unique Caido identifier per type.
5
4
  * @category Utils
@@ -15,21 +14,6 @@ export type ID = string & {
15
14
  export type HTTPQL = string & {
16
15
  __httpql?: never;
17
16
  };
18
- /**
19
- * A STREAMQL expression.
20
- * @example `ws.raw.cont:"hello"`
21
- * @category Utils
22
- */
23
- export type StreamQL = string & {
24
- __streamql?: never;
25
- };
26
- /**
27
- * A query input.
28
- * @example `"req.method.eq:'POST'"`
29
- * @example `"ws.raw.cont:'hello'"`
30
- * @category Utils
31
- */
32
- export type QueryInput = HTTPQL | StreamQL;
33
17
  /**
34
18
  * A {@link https://fontawesome.com/icons|FontAwesome} icon class.
35
19
  * @example "fas fa-rocket"
@@ -38,25 +22,13 @@ export type QueryInput = HTTPQL | StreamQL;
38
22
  export type Icon = string & {
39
23
  __icon?: never;
40
24
  };
41
- /**
42
- * A set of properties that can be passed to a component.
43
- * @category Utils
44
- */
45
- export type ComponentProps = Record<string, unknown>;
46
- /**
47
- * A set of properties that can be passed to a component definition with the SDK.
48
- * @category Utils
49
- */
50
- export type ComponentPropsWithSdk<TProps extends ComponentProps> = TProps & {
51
- sdk: API;
52
- };
53
25
  /**
54
26
  * A custom component that will be rendered in the UI.
55
27
  * @category Utils
56
28
  */
57
- export type ComponentDefinition<TProps = ComponentProps> = {
58
- component: VueComponent<TProps>;
59
- props?: TProps;
29
+ export type ComponentDefinition = {
30
+ component: VueComponent;
31
+ props?: Record<string, unknown>;
60
32
  events?: Record<string, (...args: unknown[]) => void>;
61
33
  };
62
34
  /**
@@ -1,5 +1,3 @@
1
- import { type EditorView } from "@codemirror/view";
2
- import type { As, ComponentDefinition, ComponentPropsWithSdk, ID, Prettify } from "./utils";
3
1
  /**
4
2
  * Certificate page context.
5
3
  * @category Websockets
@@ -7,49 +5,3 @@ import type { As, ComponentDefinition, ComponentPropsWithSdk, ID, Prettify } fro
7
5
  export type WebsocketPageContext = {
8
6
  kind: "Websocket";
9
7
  };
10
- /**
11
- * A complete message with all metadata and raw content.
12
- * @category Websockets
13
- */
14
- export type StreamWsMessageMeta = Prettify<As<"StreamWsMessageMeta"> & {
15
- id: ID;
16
- streamId: ID;
17
- head: {
18
- id: ID;
19
- length: number;
20
- direction: "CLIENT" | "SERVER";
21
- format: "BINARY" | "CLOSE" | "PING" | "PONG" | "TEXT";
22
- createdAt: Date;
23
- };
24
- }>;
25
- /**
26
- * The internal props for the message view mode.
27
- * @category Websockets
28
- */
29
- export type MessageViewModePropsInternal = {
30
- message: StreamWsMessageMeta;
31
- view: EditorView;
32
- };
33
- /**
34
- * The props for the message view mode.
35
- * @category Websockets
36
- */
37
- export type MessageViewModeProps = ComponentPropsWithSdk<MessageViewModePropsInternal>;
38
- /**
39
- * Options for defining a custom message view mode.
40
- * @category Websockets
41
- */
42
- export type MessageViewModeOptions<TProps extends MessageViewModeProps | MessageViewModePropsInternal> = {
43
- /**
44
- * The label of the view mode.
45
- */
46
- label: string;
47
- /**
48
- * The component to render when the view mode is selected.
49
- */
50
- view: ComponentDefinition<TProps>;
51
- /**
52
- * A function that determines if the view mode should be shown for a given message.
53
- */
54
- when?: (message: StreamWsMessageMeta) => boolean;
55
- };
@@ -15,7 +15,6 @@ import type { ReplayPageContext } from "./replay";
15
15
  import type { ScopePageContext } from "./scopes";
16
16
  import type { SearchPageContext } from "./search";
17
17
  import type { SitemapPageContext } from "./sitemap";
18
- import type { ComponentDefinition, ComponentProps, ComponentPropsWithSdk } from "./utils";
19
18
  import { type WebsocketPageContext } from "./websocket";
20
19
  import type { WorkflowsPageContext } from "./workflows";
21
20
  /**
@@ -30,11 +29,6 @@ export type DialogOptions = {
30
29
  modal?: boolean;
31
30
  position?: "left" | "right" | "top" | "bottom" | "center" | "topleft" | "topright" | "bottomleft" | "bottomright";
32
31
  };
33
- /**
34
- * The component definition for a dialog.
35
- * @category Window
36
- */
37
- export type DialogComponent = ComponentDefinition<ComponentPropsWithSdk<ComponentProps>>;
38
32
  /**
39
33
  * A dialog instance that can be closed programmatically.
40
34
  * @category Window
@@ -1,12 +0,0 @@
1
- import type { MessageViewModeOptions, MessageViewModeProps } from "../types/websocket";
2
- /**
3
- * Utilities to interact with websockets
4
- * @category Websockets
5
- */
6
- export type WebsocketSDK = {
7
- /**
8
- * Add a custom message view mode.
9
- * @param options The view mode options.
10
- */
11
- addMessageViewMode: (options: MessageViewModeOptions<MessageViewModeProps>) => void;
12
- };
@@ -1,20 +0,0 @@
1
- import { type ComponentPropsWithSdk } from "./utils";
2
- /**
3
- * The internal props for the command palette view.
4
- * @category Command Palette
5
- */
6
- export type CommandPaletteViewPropsInternal = {
7
- /**
8
- * The function to call when the command palette is closed.
9
- */
10
- onClose: () => void;
11
- /**
12
- * The function to call when the command palette is backed.
13
- */
14
- onBack: () => void;
15
- };
16
- /**
17
- * The props for the command palette view.
18
- * @category Command Palette
19
- */
20
- export type CommandPaletteViewProps = ComponentPropsWithSdk<CommandPaletteViewPropsInternal>;