@caido/sdk-frontend 0.56.1 → 0.56.3-beta.0

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,28 @@
1
- import { type ButtonSlotContent, type CommandSlotContent, type CustomSlotContent } from "./slots";
1
+ import { type ButtonSlotContent, type CommandSlotContent, type CustomSlotContent, type SlotContentProps, type SlotContentPropsGroup } from "./slots";
2
2
  import { type ID, type Selection } from "./utils";
3
+ /**
4
+ * The connection information to use for the request.
5
+ * @category Replay
6
+ */
7
+ type ConnectionInfo = {
8
+ /**
9
+ * The host to use for the request.
10
+ */
11
+ host: string;
12
+ /**
13
+ * The port to use for the request.
14
+ */
15
+ port: number;
16
+ /**
17
+ * Whether the request is TLS.
18
+ */
19
+ isTLS: boolean;
20
+ /**
21
+ * The SNI to use for the request.
22
+ * If not provided, the SNI will be inferred from the host.
23
+ */
24
+ SNI?: string;
25
+ };
3
26
  /**
4
27
  * The slots in the Replay UI.
5
28
  * @category Replay
@@ -19,10 +42,12 @@ export declare const ReplaySlot: {
19
42
  readonly Topbar: "topbar";
20
43
  };
21
44
  export type ReplaySlot = (typeof ReplaySlot)[keyof typeof ReplaySlot];
22
- export type ReplaySlotContent = {
23
- [ReplaySlot.SessionToolbarPrimary]: ButtonSlotContent | CustomSlotContent | CommandSlotContent;
24
- [ReplaySlot.SessionToolbarSecondary]: ButtonSlotContent | CustomSlotContent | CommandSlotContent;
25
- [ReplaySlot.Topbar]: ButtonSlotContent | CustomSlotContent | CommandSlotContent;
45
+ /**
46
+ * Content that can be added to replay slots.
47
+ * @category Replay
48
+ */
49
+ export type ReplaySlotContent<TProps extends SlotContentPropsGroup = SlotContentProps> = {
50
+ [K in ReplaySlot]: ButtonSlotContent | CustomSlotContent<TProps> | CommandSlotContent;
26
51
  };
27
52
  /**
28
53
  * Options for opening a tab.
@@ -108,49 +133,6 @@ export type ReplayCollection = {
108
133
  * @category Replay
109
134
  */
110
135
  export type SendRequestOptions = {
111
- /**
112
- * The connection information to use for the request.
113
- */
114
- connectionInfo: {
115
- /**
116
- * The host to use for the request.
117
- */
118
- host: string;
119
- /**
120
- * The port to use for the request.
121
- */
122
- port: number;
123
- /**
124
- * Whether the request is TLS.
125
- */
126
- isTLS: boolean;
127
- /**
128
- * The SNI to use for the request.
129
- * If not provided, the SNI will be inferred from the host.
130
- */
131
- SNI?: string;
132
- };
133
- /**
134
- * The raw request to send.
135
- */
136
- raw: string;
137
- /**
138
- * Whether to update the content length automatically to match the body.
139
- * Defaults to true.
140
- */
141
- updateContentLength?: boolean;
142
- /**
143
- * Whether to force close the connection by setting Connection: close header.
144
- * Defaults to true.
145
- */
146
- connectionClose?: boolean;
147
- /**
148
- * Whether to overwrite the editor's draft content.
149
- * If true, draft content will be overwritten with the new request.
150
- * If false, the draft will be kept.
151
- * Defaults to true.
152
- */
153
- overwriteDraft?: boolean;
154
136
  /**
155
137
  * Whether to send the request in the background without updating the UI.
156
138
  * If true, the request will not update the UI.
@@ -183,7 +165,7 @@ export type SendRequestOptions = {
183
165
  export type RequestSource = {
184
166
  type: "Raw";
185
167
  raw: string;
186
- connectionInfo: SendRequestOptions["connectionInfo"];
168
+ connectionInfo: ConnectionInfo;
187
169
  } | {
188
170
  type: "ID";
189
171
  id: string;
@@ -1,3 +1,5 @@
1
+ import { type EditorView } from "@codemirror/view";
2
+ import { type API } from "../sdks";
1
3
  import { type As, type ComponentDefinition, type ID, type Prettify } from "./utils";
2
4
  /**
3
5
  * A draft request that has not yet been saved to the database.
@@ -38,11 +40,47 @@ export type RequestFull = Prettify<As<"RequestFull"> & {
38
40
  streamId: ID | undefined;
39
41
  raw: string;
40
42
  }>;
43
+ /**
44
+ * The internal props for the request read-only view mode.
45
+ * @category Request
46
+ */
47
+ export type RequestReadableViewModePropsInternal = {
48
+ request: RequestFull;
49
+ view: EditorView;
50
+ };
51
+ /**
52
+ * The internal props for the request writable view mode.
53
+ * @category Request
54
+ */
55
+ export type RequestWritableViewModePropsInternal = {
56
+ request: RequestFull | undefined;
57
+ draft: RequestDraft;
58
+ view: EditorView;
59
+ };
60
+ /**
61
+ * The props for the request writable view mode.
62
+ * @category Request
63
+ */
64
+ export type RequestWritableViewModeProps = RequestWritableViewModePropsInternal & {
65
+ sdk: API;
66
+ };
67
+ /**
68
+ * The props for the request read-only view mode.
69
+ * @category Request
70
+ */
71
+ export type RequestReadableViewModeProps = RequestReadableViewModePropsInternal & {
72
+ sdk: API;
73
+ };
74
+ /**
75
+ * The props group for the request view mode.
76
+ * @category Request
77
+ */
78
+ export type RequestViewModeProps = RequestReadableViewModeProps | RequestWritableViewModeProps | RequestReadableViewModePropsInternal | RequestWritableViewModePropsInternal;
41
79
  /**
42
80
  * Options for defining a custom request view mode.
43
81
  * @category Request
44
82
  */
45
- export type RequestViewModeOptions = {
83
+ export type RequestViewModeOptions<TProps extends RequestViewModeProps> = {
46
84
  /**
47
85
  * The label of the view mode.
48
86
  */
@@ -50,7 +88,7 @@ export type RequestViewModeOptions = {
50
88
  /**
51
89
  * The component to render when the view mode is selected.
52
90
  */
53
- view: ComponentDefinition;
91
+ view: ComponentDefinition<TProps>;
54
92
  /**
55
93
  * A function that determines if the view mode should be shown for a given request.
56
94
  */
@@ -1,3 +1,5 @@
1
+ import { type EditorView } from "@codemirror/view";
2
+ import { type API } from "../sdks";
1
3
  import type { RequestFull, RequestMeta } from "./request";
2
4
  import type { As, ComponentDefinition, ID, Prettify } from "./utils";
3
5
  /**
@@ -12,11 +14,26 @@ export type ResponseFull = Prettify<As<"ResponseFull"> & {
12
14
  length: number;
13
15
  createdAt: Date;
14
16
  }>;
17
+ /**
18
+ * The internal props for the response view mode.
19
+ * @category Response
20
+ */
21
+ export type ResponseViewModePropsInternal = {
22
+ response: ResponseFull;
23
+ view: EditorView;
24
+ };
25
+ /**
26
+ * The props for the response view mode.
27
+ * @category Response
28
+ */
29
+ export type ResponseViewModeProps = ResponseViewModePropsInternal & {
30
+ sdk: API;
31
+ };
15
32
  /**
16
33
  * Options for defining a custom response view mode.
17
34
  * @category Response
18
35
  */
19
- export type ResponseViewModeOptions = {
36
+ export type ResponseViewModeOptions<TProps extends ResponseViewModeProps | ResponseViewModePropsInternal> = {
20
37
  /**
21
38
  * The label of the view mode.
22
39
  */
@@ -24,7 +41,7 @@ export type ResponseViewModeOptions = {
24
41
  /**
25
42
  * The component to render when the view mode is selected.
26
43
  */
27
- view: ComponentDefinition;
44
+ view: ComponentDefinition<TProps>;
28
45
  /**
29
46
  * A function that determines if the view mode should be shown for a given response.
30
47
  */
@@ -1,4 +1,4 @@
1
- import { type ButtonSlotContent, type CommandSlotContent, type CustomSlotContent } from "./slots";
1
+ import { type ButtonSlotContent, type CommandSlotContent, type CustomSlotContent, type SlotContentProps, type SlotContentPropsGroup } from "./slots";
2
2
  import { type ID, type Selection } from "./utils";
3
3
  /**
4
4
  * Represents a scope.
@@ -37,9 +37,12 @@ export declare const ScopeSlot: {
37
37
  readonly CreateHeader: "create-header";
38
38
  };
39
39
  export type ScopeSlot = (typeof ScopeSlot)[keyof typeof ScopeSlot];
40
- export type ScopeSlotContent = {
41
- [ScopeSlot.UpdateHeader]: ButtonSlotContent | CustomSlotContent | CommandSlotContent;
42
- [ScopeSlot.CreateHeader]: ButtonSlotContent | CustomSlotContent | CommandSlotContent;
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;
43
46
  };
44
47
  /**
45
48
  * Event fired when the current scope changes.
@@ -1,4 +1,4 @@
1
- import { type ButtonSlotContent, type CommandSlotContent, type CustomSlotContent } from "./slots";
1
+ import { type ButtonSlotContent, type CommandSlotContent, type CustomSlotContent, type SlotContentProps, type SlotContentPropsGroup } from "./slots";
2
2
  /**
3
3
  * The slots in the Search UI.
4
4
  * @category Search
@@ -10,8 +10,12 @@ export declare const SearchSlot: {
10
10
  readonly ToolbarPrimary: "search-toolbar-primary";
11
11
  };
12
12
  export type SearchSlot = (typeof SearchSlot)[keyof typeof SearchSlot];
13
- export type SearchSlotContent = {
14
- [SearchSlot.ToolbarPrimary]: ButtonSlotContent | CustomSlotContent | CommandSlotContent;
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;
15
19
  };
16
20
  /**
17
21
  * Search page context.
@@ -1,8 +1,26 @@
1
+ import { type API } from "../sdks";
1
2
  import { type CommandID } from "./commands";
2
3
  import { type ComponentDefinition, type Prettify } from "./utils";
3
4
  type DefineSlotContent<TType extends string, P extends Record<string, unknown>> = Prettify<{
4
5
  type: TType;
5
6
  } & P>;
7
+ /**
8
+ * The internal props for a slot content.
9
+ * @category Slots
10
+ */
11
+ export type SlotContentPropsInternal = {};
12
+ /**
13
+ * The props for a slot content.
14
+ * @category Slots
15
+ */
16
+ export type SlotContentProps = SlotContentPropsInternal & {
17
+ sdk: API;
18
+ };
19
+ /**
20
+ * The props group for a slot content.
21
+ * @category Slots
22
+ */
23
+ export type SlotContentPropsGroup = SlotContentProps | SlotContentPropsInternal;
6
24
  /**
7
25
  * Content for a button slot.
8
26
  * @category Slots
@@ -16,8 +34,8 @@ export type ButtonSlotContent = DefineSlotContent<"Button", {
16
34
  * Content for a custom component slot.
17
35
  * @category Slots
18
36
  */
19
- export type CustomSlotContent = DefineSlotContent<"Custom", {
20
- definition: ComponentDefinition;
37
+ export type CustomSlotContent<TProps extends SlotContentPropsGroup = SlotContentProps> = DefineSlotContent<"Custom", {
38
+ definition: ComponentDefinition<TProps>;
21
39
  }>;
22
40
  /**
23
41
  * Content for a command slot.
@@ -31,7 +49,7 @@ export type CommandSlotContent = DefineSlotContent<"Command", {
31
49
  * Union type of all possible slot content types.
32
50
  * @category Slots
33
51
  */
34
- export type SlotContent = ButtonSlotContent | CustomSlotContent | CommandSlotContent;
52
+ export type SlotContent<TProps extends SlotContentPropsGroup = SlotContentProps> = ButtonSlotContent | CustomSlotContent<TProps> | CommandSlotContent;
35
53
  /**
36
54
  * A function type for adding content to slots.
37
55
  * @category Slots
@@ -1,4 +1,5 @@
1
1
  import { type Component as VueComponent } from "vue";
2
+ import { type API } from "../index";
2
3
  /**
3
4
  * A unique Caido identifier per type.
4
5
  * @category Utils
@@ -14,6 +15,21 @@ export type ID = string & {
14
15
  export type HTTPQL = string & {
15
16
  __httpql?: never;
16
17
  };
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;
17
33
  /**
18
34
  * A {@link https://fontawesome.com/icons|FontAwesome} icon class.
19
35
  * @example "fas fa-rocket"
@@ -22,13 +38,25 @@ export type HTTPQL = string & {
22
38
  export type Icon = string & {
23
39
  __icon?: never;
24
40
  };
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
+ };
25
53
  /**
26
54
  * A custom component that will be rendered in the UI.
27
55
  * @category Utils
28
56
  */
29
- export type ComponentDefinition = {
30
- component: VueComponent;
31
- props?: Record<string, unknown>;
57
+ export type ComponentDefinition<TProps = ComponentProps> = {
58
+ component: VueComponent<TProps>;
59
+ props?: ComponentProps;
32
60
  events?: Record<string, (...args: unknown[]) => void>;
33
61
  };
34
62
  /**
@@ -1,3 +1,5 @@
1
+ import { type EditorView } from "@codemirror/view";
2
+ import type { As, ComponentDefinition, ComponentPropsWithSdk, ID, Prettify } from "./utils";
1
3
  /**
2
4
  * Certificate page context.
3
5
  * @category Websockets
@@ -5,3 +7,49 @@
5
7
  export type WebsocketPageContext = {
6
8
  kind: "Websocket";
7
9
  };
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,6 +15,7 @@ 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";
18
19
  import { type WebsocketPageContext } from "./websocket";
19
20
  import type { WorkflowsPageContext } from "./workflows";
20
21
  /**
@@ -29,6 +30,11 @@ export type DialogOptions = {
29
30
  modal?: boolean;
30
31
  position?: "left" | "right" | "top" | "bottom" | "center" | "topleft" | "topright" | "bottomleft" | "bottomright";
31
32
  };
33
+ /**
34
+ * The component definition for a dialog.
35
+ * @category Window
36
+ */
37
+ export type DialogComponent = ComponentDefinition<ComponentPropsWithSdk<ComponentProps>>;
32
38
  /**
33
39
  * A dialog instance that can be closed programmatically.
34
40
  * @category Window