@caido/sdk-frontend 0.57.1 → 0.57.2-beta.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,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
  * The slots in the HTTP History UI.
@@ -11,8 +11,12 @@ export declare const HTTPHistorySlot: {
11
11
  readonly ToolbarPrimary: "toolbar-primary";
12
12
  };
13
13
  export type HTTPHistorySlot = (typeof HTTPHistorySlot)[keyof typeof HTTPHistorySlot];
14
- export type HTTPHistorySlotContent = {
15
- [HTTPHistorySlot.ToolbarPrimary]: ButtonSlotContent | CustomSlotContent | CommandSlotContent;
14
+ /**
15
+ * Content that can be added to HTTP history slots.
16
+ * @category HTTP History
17
+ */
18
+ export type HTTPHistorySlotContent<TProps extends SlotContentPropsGroup = SlotContentProps> = {
19
+ [K in HTTPHistorySlot]: ButtonSlotContent | CustomSlotContent<TProps> | CommandSlotContent;
16
20
  };
17
21
  /**
18
22
  * HTTP history page context.
@@ -0,0 +1,3 @@
1
+ export type HTTPQLEditorProps = {
2
+ isReadOnly?: boolean;
3
+ };
@@ -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 HTTPQL, type ID, type Selection } from "./utils";
3
3
  /**
4
4
  * A rule in Match and Replace.
@@ -448,9 +448,8 @@ export type MatchReplaceSlot = (typeof MatchReplaceSlot)[keyof typeof MatchRepla
448
448
  * Content that can be added to match and replace slots.
449
449
  * @category Match and Replace
450
450
  */
451
- export type MatchReplaceSlotContent = {
452
- [MatchReplaceSlot.UpdateHeader]: ButtonSlotContent | CustomSlotContent | CommandSlotContent;
453
- [MatchReplaceSlot.CreateHeader]: ButtonSlotContent | CustomSlotContent | CommandSlotContent;
451
+ export type MatchReplaceSlotContent<TProps extends SlotContentPropsGroup = SlotContentProps> = {
452
+ [K in MatchReplaceSlot]: ButtonSlotContent | CustomSlotContent<TProps> | CommandSlotContent;
454
453
  };
455
454
  /**
456
455
  * Event fired when the current match and replace rule changes.
@@ -1,5 +1,7 @@
1
- import { type ButtonSlotContent, type CommandSlotContent, type CustomSlotContent } from "./slots";
2
- import { type ID, type Selection } from "./utils";
1
+ import type { RequestFull } from "./request";
2
+ import type { ResponseFull } from "./response";
3
+ import { type ButtonSlotContent, type CommandSlotContent, type CustomSlotContent, type SlotContentProps, type SlotContentPropsGroup } from "./slots";
4
+ import { type AddIndicatorOptions, type ID, type Selection } from "./utils";
3
5
  /**
4
6
  * The connection information to use for the request.
5
7
  * @category Replay
@@ -42,10 +44,12 @@ export declare const ReplaySlot: {
42
44
  readonly Topbar: "topbar";
43
45
  };
44
46
  export type ReplaySlot = (typeof ReplaySlot)[keyof typeof ReplaySlot];
45
- export type ReplaySlotContent = {
46
- [ReplaySlot.SessionToolbarPrimary]: ButtonSlotContent | CustomSlotContent | CommandSlotContent;
47
- [ReplaySlot.SessionToolbarSecondary]: ButtonSlotContent | CustomSlotContent | CommandSlotContent;
48
- [ReplaySlot.Topbar]: ButtonSlotContent | CustomSlotContent | CommandSlotContent;
47
+ /**
48
+ * Content that can be added to replay slots.
49
+ * @category Replay
50
+ */
51
+ export type ReplaySlotContent<TProps extends SlotContentPropsGroup = SlotContentProps> = {
52
+ [K in ReplaySlot]: ButtonSlotContent | CustomSlotContent<TProps> | CommandSlotContent;
49
53
  };
50
54
  /**
51
55
  * Options for opening a tab.
@@ -108,6 +112,35 @@ export type ReplayEntry = {
108
112
  */
109
113
  requestId?: ID;
110
114
  };
115
+ /**
116
+ * The currently selected Replay exchange.
117
+ * @category Replay
118
+ */
119
+ export type ReplaySelectedExchange = {
120
+ kind: typeof ReplaySessionKind.Http;
121
+ entryId: ID;
122
+ sessionId: ID;
123
+ request: RequestFull;
124
+ response?: ResponseFull;
125
+ } | {
126
+ kind: typeof ReplaySessionKind.Ws;
127
+ entryId: ID;
128
+ sessionId: ID;
129
+ streamId?: ID;
130
+ activeTab: "http-upgrade" | "messages";
131
+ upgradeRequest?: RequestFull;
132
+ upgradeResponse?: ResponseFull;
133
+ message?: ReplayWebSocketMessage;
134
+ };
135
+ /**
136
+ * The currently edited WebSocket message in Replay.
137
+ * @category Replay
138
+ */
139
+ export type ReplayWebSocketMessage = {
140
+ raw: string;
141
+ direction: "CLIENT" | "SERVER";
142
+ format: "BINARY" | "CLOSE" | "PING" | "PONG" | "TEXT";
143
+ };
111
144
  /**
112
145
  * A collection in Replay.
113
146
  * @category Replay
@@ -206,6 +239,35 @@ export type ReplayPageContext = {
206
239
  kind: "Replay";
207
240
  selection: Selection<ReplaySessionId>;
208
241
  };
242
+ /**
243
+ * Options for adding an indicator to a replay session.
244
+ * @category Replay
245
+ */
246
+ export type AddSessionIndicatorOptions = AddIndicatorOptions & {
247
+ /**
248
+ * Includes the indicator icon on the session's replay tab.
249
+ * @default false
250
+ */
251
+ showTabIcon?: boolean;
252
+ };
253
+ /**
254
+ * Options for adding an indicator to a replay collection.
255
+ * @category Replay
256
+ */
257
+ export type AddCollectionIndicatorOptions = AddIndicatorOptions;
258
+ /**
259
+ * The kind of a replay session.
260
+ * @category Replay
261
+ */
262
+ export declare const ReplaySessionKind: {
263
+ readonly Http: "HTTP";
264
+ readonly Ws: "WS";
265
+ };
266
+ /**
267
+ * The kind of a replay session.
268
+ * @category Replay
269
+ */
270
+ export type ReplaySessionKind = (typeof ReplaySessionKind)[keyof typeof ReplaySessionKind];
209
271
  /**
210
272
  * A unique replay session identifier.
211
273
  * @category Replay
@@ -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
@@ -37,13 +38,25 @@ export type QueryInput = HTTPQL | StreamQL;
37
38
  export type Icon = string & {
38
39
  __icon?: never;
39
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
+ };
40
53
  /**
41
54
  * A custom component that will be rendered in the UI.
42
55
  * @category Utils
43
56
  */
44
- export type ComponentDefinition = {
45
- component: VueComponent;
46
- props?: Record<string, unknown>;
57
+ export type ComponentDefinition<TProps = ComponentProps> = {
58
+ component: VueComponent<TProps>;
59
+ props?: ComponentProps;
47
60
  events?: Record<string, (...args: unknown[]) => void>;
48
61
  };
49
62
  /**
@@ -1,4 +1,5 @@
1
- import type { As, ComponentDefinition, ID, Prettify } from "./utils";
1
+ import { type EditorView } from "@codemirror/view";
2
+ import type { As, ComponentDefinition, ComponentPropsWithSdk, ID, Prettify } from "./utils";
2
3
  /**
3
4
  * Certificate page context.
4
5
  * @category Websockets
@@ -21,11 +22,24 @@ export type StreamWsMessageMeta = Prettify<As<"StreamWsMessageMeta"> & {
21
22
  createdAt: Date;
22
23
  };
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>;
24
38
  /**
25
39
  * Options for defining a custom message view mode.
26
40
  * @category Websockets
27
41
  */
28
- export type MessageViewModeOptions = {
42
+ export type MessageViewModeOptions<TProps extends MessageViewModeProps | MessageViewModePropsInternal> = {
29
43
  /**
30
44
  * The label of the view mode.
31
45
  */
@@ -33,7 +47,7 @@ export type MessageViewModeOptions = {
33
47
  /**
34
48
  * The component to render when the view mode is selected.
35
49
  */
36
- view: ComponentDefinition;
50
+ view: ComponentDefinition<TProps>;
37
51
  /**
38
52
  * A function that determines if the view mode should be shown for a given message.
39
53
  */
@@ -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