@caido/sdk-frontend 0.52.0 → 0.52.1-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.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@caido/sdk-frontend",
3
- "version": "v0.52.0",
3
+ "version": "0.52.1-beta.1",
4
4
  "description": "Typing for the Caido Frontend SDK",
5
5
  "author": "Caido Labs Inc. <dev@caido.io>",
6
6
  "license": "MIT",
@@ -2,7 +2,7 @@ export { FooterSlot, type FooterSlotContent } from "./types/footer";
2
2
  export type { DialogOptions } from "./types/window";
3
3
  export type { CommandContext, CommandContextRequest, CommandContextRequestRow, CommandContextResponse, CommandContextBase, } from "./types/commands";
4
4
  export type { MenuItem } from "./types/menu";
5
- export { type ReplayTab, type ReplaySession, type ReplayCollection, type SendRequestOptions, ReplaySlot, type ReplaySlotContent, type RequestSource, } from "./types/replay";
5
+ export { type ReplayTab, type ReplaySession, type ReplayCollection, type SendRequestOptions, ReplaySlot, type ReplaySlotContent, type RequestSource, type CurrentReplaySessionChangeEvent, } from "./types/replay";
6
6
  export type { HostedFile } from "./types/files";
7
7
  export type { Filter } from "./types/filter";
8
8
  export type { HTTPQL, ID, ComponentDefinition } from "./types/utils";
@@ -15,4 +15,8 @@ export type { EnvironmentVariable } from "./types/environment";
15
15
  export type { Workflow, WorkflowKind, OnCreatedWorkflowCallback, OnUpdatedWorkflowCallback, OnDeletedWorkflowCallback, } from "./types/workflows";
16
16
  export type { ListenerHandle } from "./types/utils";
17
17
  export type { AIProvider } from "./types/ai";
18
+ export type { SelectedProjectChangeEvent } from "./types/projects";
19
+ export type { CommandPaletteView } from "./sdks/commandPalette";
20
+ export type { LogSDK } from "./sdks/log";
18
21
  export type { API } from "./sdks";
22
+ export { Routes } from "./types/navigation";
@@ -1,4 +1,13 @@
1
1
  import { type CommandID } from "../types/commands";
2
+ import { type ComponentDefinition } from "../types/utils";
3
+ /**
4
+ * Command palette view definition for custom UI content.
5
+ * @category Command Palette
6
+ */
7
+ export type CommandPaletteView = {
8
+ type: "Custom";
9
+ definition: ComponentDefinition;
10
+ };
2
11
  /**
3
12
  * Utilities to interact with the command palette.
4
13
  * @category Command Palette
@@ -9,4 +18,9 @@ export type CommandPaletteSDK = {
9
18
  * @param commandId The id of the command to register.
10
19
  */
11
20
  register: (commandId: CommandID) => void;
21
+ /**
22
+ * Push a new view onto the command palette view stack.
23
+ * @param view The view to push onto the stack.
24
+ */
25
+ pushView: (view: CommandPaletteView) => void;
12
26
  };
@@ -13,9 +13,11 @@ import type { FindingsSDK } from "./findings";
13
13
  import type { FooterSDK } from "./footer";
14
14
  import type { HTTPHistorySDK } from "./httpHistory";
15
15
  import type { InterceptSDK } from "./intercept";
16
+ import type { LogSDK } from "./log";
16
17
  import type { MatchReplaceSDK } from "./matchReplace";
17
18
  import type { MenuSDK } from "./menu";
18
19
  import type { NavigationSDK } from "./navigation";
20
+ import type { ProjectsSDK } from "./projects";
19
21
  import type { ReplaySDK } from "./replay";
20
22
  import type { RuntimeSDK } from "./runtime";
21
23
  import type { ScopesSDK } from "./scopes";
@@ -68,6 +70,10 @@ export type API<T extends BackendEndpoints = Record<string, never>, E extends Ba
68
70
  * Utilities to interact with navigation.
69
71
  */
70
72
  navigation: NavigationSDK;
73
+ /**
74
+ * Utilities to interact with projects.
75
+ */
76
+ projects: ProjectsSDK;
71
77
  /**
72
78
  * Utilities to interact with the active page.
73
79
  */
@@ -144,4 +150,8 @@ export type API<T extends BackendEndpoints = Record<string, never>, E extends Ba
144
150
  * Utilities to interact with the footer.
145
151
  */
146
152
  footer: FooterSDK;
153
+ /**
154
+ * Utilities for logging messages to the console.
155
+ */
156
+ log: LogSDK;
147
157
  };
@@ -0,0 +1,22 @@
1
+ /**
2
+ * Utilities to log messages to the console.
3
+ * @category Log
4
+ */
5
+ export type LogSDK = {
6
+ /**
7
+ * Log info message with variable arguments
8
+ */
9
+ info: (...data: unknown[]) => void;
10
+ /**
11
+ * Log warning message with variable arguments
12
+ */
13
+ warn: (...data: unknown[]) => void;
14
+ /**
15
+ * Log debug message with variable arguments
16
+ */
17
+ debug: (...data: unknown[]) => void;
18
+ /**
19
+ * Log error message with variable arguments
20
+ */
21
+ error: (...data: unknown[]) => void;
22
+ };
@@ -1,18 +1,24 @@
1
+ import { type PageChangeEvent, type Routes } from "../types/navigation";
2
+ import { type ListenerHandle } from "../types/utils";
1
3
  /**
2
4
  * Utilities to interact with navigation.
3
5
  * @category Navigation
4
6
  */
5
7
  export type NavigationSDK = {
6
8
  /**
7
- * Navigate to a path.
8
- * @param path The path to navigate to.
9
+ * Navigate to a route or path.
10
+ * @param route The route to navigate to. Can be a route ID object or a custom path string.
9
11
  *
10
12
  * @example
11
13
  * ```ts
14
+ * sdk.navigation.goTo({ id: Routes.Replay });
15
+ * sdk.navigation.goTo({ id: Routes.Projects });
12
16
  * sdk.navigation.goTo("/my-plugin-page");
13
17
  * ```
14
18
  */
15
- goTo: (path: string) => void;
19
+ goTo: (route: string | {
20
+ id: Routes;
21
+ }) => void;
16
22
  /**
17
23
  * Add a page to the navigation.
18
24
  * @param path The path of the page.
@@ -26,4 +32,21 @@ export type NavigationSDK = {
26
32
  topbar?: HTMLElement;
27
33
  onEnter?: () => void;
28
34
  }) => void;
35
+ /**
36
+ * Subscribe to page changes.
37
+ * @param callback The callback to call when the page changes.
38
+ * @returns An object with a `stop` method that can be called to stop listening to page changes.
39
+ *
40
+ * @example
41
+ * ```ts
42
+ * const handler = sdk.navigation.onPageChange((event) => {
43
+ * console.log('Page changed to:', event.routeId);
44
+ * console.log('- path:', event.path);
45
+ * });
46
+ *
47
+ * // Later, stop listening
48
+ * handler.stop();
49
+ * ```
50
+ */
51
+ onPageChange: (callback: (route: PageChangeEvent) => void) => ListenerHandle;
29
52
  };
@@ -0,0 +1,24 @@
1
+ import { type SelectedProjectChangeEvent } from "../types/projects";
2
+ import { type ListenerHandle } from "../types/utils";
3
+ /**
4
+ * Utilities to interact with projects.
5
+ * @category Projects
6
+ */
7
+ export type ProjectsSDK = {
8
+ /**
9
+ * Subscribe to selected project changes.
10
+ * @param callback The callback to call when the selected project changes.
11
+ * @returns An object with a `stop` method that can be called to stop listening to project changes.
12
+ *
13
+ * @example
14
+ * ```ts
15
+ * const handler = sdk.projects.onCurrentProjectChange((event) => {
16
+ * console.log('Selected project changed to:', event.projectId);
17
+ * });
18
+ *
19
+ * // Later, stop listening
20
+ * handler.stop();
21
+ * ```
22
+ */
23
+ onCurrentProjectChange: (callback: (event: SelectedProjectChangeEvent) => void) => ListenerHandle;
24
+ };
@@ -1,8 +1,8 @@
1
1
  import { type Extension } from "@codemirror/state";
2
- import { type OpenTabOptions, type ReplayCollection, type ReplaySession, type ReplaySlotContent, type ReplayTab, type RequestSource, type SendRequestOptions } from "../types/replay";
2
+ import { type CurrentReplaySessionChangeEvent, type OpenTabOptions, type ReplayCollection, type ReplaySession, type ReplaySlotContent, type ReplayTab, type RequestSource, type SendRequestOptions } from "../types/replay";
3
3
  import type { RequestViewModeOptions } from "../types/request";
4
4
  import { type DefineAddToSlotFn } from "../types/slots";
5
- import type { ID } from "../types/utils";
5
+ import type { ID, ListenerHandle } from "../types/utils";
6
6
  /**
7
7
  * Utilities to interact with Replay.
8
8
  * @category Replay
@@ -134,4 +134,20 @@ export type ReplaySDK = {
134
134
  * ```
135
135
  */
136
136
  sendRequest: (sessionId: ID, options: SendRequestOptions) => Promise<void>;
137
+ /**
138
+ * Subscribe to current replay session changes.
139
+ * @param callback The callback to call when the selected session changes.
140
+ * @returns An object with a `stop` method that can be called to stop listening to session changes.
141
+ *
142
+ * @example
143
+ * ```ts
144
+ * const handler = sdk.replay.onCurrentSessionChange((event) => {
145
+ * console.log(`Session ${event.sessionId} got selected!`);
146
+ * });
147
+ *
148
+ * // Later, stop listening
149
+ * handler.stop();
150
+ * ```
151
+ */
152
+ onCurrentSessionChange: (callback: (event: CurrentReplaySessionChangeEvent) => void) => ListenerHandle;
137
153
  };
@@ -0,0 +1,33 @@
1
+ export declare const Routes: {
2
+ readonly Sitemap: "Sitemap";
3
+ readonly Intercept: "Intercept";
4
+ readonly Search: "Search";
5
+ readonly HTTPHistory: "HTTPHistory";
6
+ readonly Websockets: "Websockets";
7
+ readonly Workflows: "Workflows";
8
+ readonly Replay: "Replay";
9
+ readonly Automate: "Automate";
10
+ readonly Projects: "Projects";
11
+ readonly Backups: "Backups";
12
+ readonly MatchReplace: "Tamper";
13
+ readonly Assistant: "Assistant";
14
+ readonly Environment: "Environment";
15
+ readonly Scope: "Scope";
16
+ readonly Filter: "Filter";
17
+ readonly Exports: "Exports";
18
+ readonly Findings: "Findings";
19
+ readonly Files: "Files";
20
+ readonly Plugins: "Plugins";
21
+ readonly Certificate: "Certificate";
22
+ readonly About: "About";
23
+ readonly Settings: "Settings";
24
+ };
25
+ export type Routes = (typeof Routes)[keyof typeof Routes];
26
+ export type PageChangeEvent = {
27
+ type: "Core";
28
+ routeId: Routes;
29
+ path: string;
30
+ } | {
31
+ type: "Plugin";
32
+ path: string;
33
+ };
@@ -0,0 +1,8 @@
1
+ import { type ID } from "./utils";
2
+ /**
3
+ * Event fired when the selected project changes.
4
+ * @category Projects
5
+ */
6
+ export type SelectedProjectChangeEvent = {
7
+ projectId: ID | undefined;
8
+ };
@@ -166,3 +166,13 @@ export type RequestSource = {
166
166
  type: "ID";
167
167
  id: string;
168
168
  };
169
+ /**
170
+ * Event fired when the current replay session changes.
171
+ * @category Replay
172
+ */
173
+ export type CurrentReplaySessionChangeEvent = {
174
+ /**
175
+ * The ID of the newly selected session, or undefined if no session is selected.
176
+ */
177
+ sessionId: ID | undefined;
178
+ };
@@ -1,8 +1,8 @@
1
1
  import { type CommandID } from "./commands";
2
- import { type ComponentDefinition } from "./utils";
3
- type DefineSlotContent<TType extends string, P extends Record<string, unknown>> = {
2
+ import { type ComponentDefinition, type Prettify } from "./utils";
3
+ type DefineSlotContent<TType extends string, P extends Record<string, unknown>> = Prettify<{
4
4
  type: TType;
5
- } & P;
5
+ } & P>;
6
6
  export type ButtonSlotContent = DefineSlotContent<"Button", {
7
7
  label: string;
8
8
  icon?: string;