@caido/sdk-frontend 0.54.2-beta.1 → 0.54.2-beta.3

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.54.2-beta.1",
3
+ "version": "0.54.2-beta.3",
4
4
  "description": "Typing for the Caido Frontend SDK",
5
5
  "author": "Caido Labs Inc. <dev@caido.io>",
6
6
  "repository": "https://github.com/caido/sdk-js/",
@@ -3,6 +3,8 @@ 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
5
  export { type ReplayTab, type ReplaySession, type ReplayEntry, type ReplayCollection, type SendRequestOptions, ReplaySlot, type ReplaySlotContent, type RequestSource, type CurrentReplaySessionChangeEvent, } from "./types/replay";
6
+ export type { AutomateSession, AutomateEntry } from "./types/automate";
7
+ export type { SitemapEntry, SitemapRootEntry, ChildState, } from "./types/sitemap";
6
8
  export { SearchSlot, type SearchSlotContent } from "./types/search";
7
9
  export type { HostedFile } from "./types/files";
8
10
  export { FilterSlot, type Filter, type FilterSlotContent, type CurrentFilterChangeEvent, } from "./types/filter";
@@ -16,7 +18,7 @@ export { ScopeSlot, type CurrentScopeChangeEvent, type Scope, type ScopeSlotCont
16
18
  export { HTTPHistorySlot, type HTTPHistorySlotContent, } from "./types/httpHistory";
17
19
  export type { EnvironmentVariable } from "./types/environment";
18
20
  export type { Workflow, WorkflowKind, OnCreatedWorkflowCallback, OnUpdatedWorkflowCallback, OnDeletedWorkflowCallback, } from "./types/workflows";
19
- export type { ListenerHandle } from "./types/utils";
21
+ export type { ListenerHandle, AddIndicatorOptions, Indicator, } from "./types/utils";
20
22
  export type { AIProvider, AILanguageModelSettings, AIReasoningSettings, AIUpstreamProvider, AIUpstreamProviderId, AIUpstreamProviderStatus, } from "./types/ai";
21
23
  export type { SelectedProjectChangeEvent } from "./types/projects";
22
24
  export type { CommandPaletteView } from "./sdks/commandPalette";
@@ -1,4 +1,6 @@
1
1
  import type { Extension } from "@codemirror/state";
2
+ import type { AutomateEntry, AutomateSession } from "src/types/automate";
3
+ import type { AddIndicatorOptions, ID, Indicator } from "src/types/utils";
2
4
  import type { RequestViewModeOptions } from "../types/request";
3
5
  /**
4
6
  * Utilities to interact with the Automate page.
@@ -15,4 +17,33 @@ export type AutomateSDK = {
15
17
  * @param options The view mode options.
16
18
  */
17
19
  addRequestViewMode: (options: RequestViewModeOptions) => void;
20
+ /**
21
+ * Get the list of all automate sessions.
22
+ * @returns The list of all automate sessions.
23
+ */
24
+ getSessions: () => AutomateSession[];
25
+ /**
26
+ * Get the list of all automate entries.
27
+ * @param sessionId The ID of the session to get the entries of.
28
+ * @returns The list of all automate entries.
29
+ */
30
+ getEntries: (sessionId: ID) => AutomateEntry[];
31
+ /**
32
+ * Add an indicator to an automate entry.
33
+ * Indicators are displayed next to the entry name in the collections tree.
34
+ * @param entryId The ID of the entry to add the indicator to.
35
+ * @param indicator The indicator configuration.
36
+ * @returns A handle object with a `remove` method to remove the indicator.
37
+ * @example
38
+ *
39
+ * const indicator = sdk.automate.addEntryIndicator(entryId, {
40
+ * icon: "fas fa-exclamation-triangle",
41
+ * description: "Security warning",
42
+ * });
43
+ *
44
+ * // Later, remove the indicator
45
+ * indicator.remove();
46
+ *
47
+ */
48
+ addEntryIndicator: (entryId: ID, indicator: AddIndicatorOptions) => Indicator;
18
49
  };
@@ -1,6 +1,6 @@
1
1
  import { type CurrentMatchReplaceRuleChangeEvent, type MatchReplaceCollection, type MatchReplaceRule, type MatchReplaceSection, type MatchReplaceSlotContent, type Source } from "../types/matchReplace";
2
2
  import { type DefineAddToSlotFn } from "../types/slots";
3
- import type { HTTPQL, ID, ListenerHandle } from "../types/utils";
3
+ import type { AddIndicatorOptions, HTTPQL, ID, Indicator, ListenerHandle } from "../types/utils";
4
4
  /**
5
5
  * Utilities to interact with the Match and Replace page.
6
6
  * @category Match and Replace
@@ -138,4 +138,22 @@ export type MatchReplaceSDK = {
138
138
  * ```
139
139
  */
140
140
  addToSlot: DefineAddToSlotFn<MatchReplaceSlotContent>;
141
+ /**
142
+ * Add an indicator to a rule.
143
+ * Indicators are displayed next to the session name in the collections tree.
144
+ * @param ruleId The ID of the rule to add the indicator to.
145
+ * @param indicator The indicator configuration.
146
+ * @returns A handle object with a `remove` method to remove the indicator.
147
+ * @example
148
+ *
149
+ * const indicator = sdk.matchReplace.addRuleIndicator(ruleId, {
150
+ * icon: "fas fa-exclamation-triangle",
151
+ * description: "Security warning",
152
+ * });
153
+ *
154
+ * // Later, remove the indicator
155
+ * indicator.remove();
156
+ *
157
+ */
158
+ addRuleIndicator: (ruleId: ID, indicator: AddIndicatorOptions) => Indicator;
141
159
  };
@@ -2,7 +2,7 @@ import { type Extension } from "@codemirror/state";
2
2
  import { type CurrentReplaySessionChangeEvent, type OpenTabOptions, type ReplayCollection, type ReplayCollectionCreatedEvent, type ReplayEntry, type ReplaySession, type ReplaySessionCreatedEvent, 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, ListenerHandle } from "../types/utils";
5
+ import type { AddIndicatorOptions, ID, Indicator, ListenerHandle } from "../types/utils";
6
6
  /**
7
7
  * Utilities to interact with Replay.
8
8
  * @category Replay
@@ -224,4 +224,22 @@ export type ReplaySDK = {
224
224
  * ```
225
225
  */
226
226
  onCollectionCreate: (callback: (event: ReplayCollectionCreatedEvent) => void) => ListenerHandle;
227
+ /**
228
+ * Add an indicator to a replay session.
229
+ * Indicators are displayed next to the session name in the collections tree.
230
+ * @param sessionId The ID of the session to add the indicator to.
231
+ * @param indicator The indicator configuration.
232
+ * @returns A handle object with a `remove` method to remove the indicator.
233
+ * @example
234
+ *
235
+ * const indicator = sdk.replay.addSessionIndicator(sessionId, {
236
+ * icon: "fas fa-exclamation-triangle",
237
+ * description: "Security warning",
238
+ * });
239
+ *
240
+ * // Later, remove the indicator
241
+ * indicator.remove();
242
+ *
243
+ */
244
+ addSessionIndicator: (sessionId: ID, indicator: AddIndicatorOptions) => Indicator;
227
245
  };
@@ -1,11 +1,38 @@
1
1
  import type { Extension } from "@codemirror/state";
2
2
  import type { RequestViewModeOptions } from "../types/request";
3
- import type { ID } from "../types/utils";
3
+ import type { SitemapEntry, SitemapEntryChildStateUpdateEvent, SitemapRootEntry } from "../types/sitemap";
4
+ import type { AddIndicatorOptions, ID, Indicator, ListenerHandle } from "../types/utils";
4
5
  /**
5
6
  * Utilities to interact with the Sitemap page.
6
7
  * @category Sitemap
7
8
  */
8
9
  export type SitemapSDK = {
10
+ /**
11
+ * Listen for child state updates on a sitemap entry.
12
+ * @param callback The callback function that receives the entry ID and new child state.
13
+ * @returns A handle object with a `stop` method to stop listening.
14
+ * @example
15
+ *
16
+ * const handle = sdk.sitemap.onEntryChildStateUpdate((entryId, newChildState) => {
17
+ * console.log(`Entry ${entryId} child state changed:`, newChildState);
18
+ * });
19
+ *
20
+ * // Later, stop listening
21
+ * handle.stop();
22
+ */
23
+ onEntryChildStateUpdate: (callback: (event: SitemapEntryChildStateUpdateEvent) => void) => ListenerHandle;
24
+ /**
25
+ * Get the list of all sitemap entries in tree format.
26
+ * @returns The list of all sitemap entries.
27
+ */
28
+ getTreeEntries: () => SitemapRootEntry[];
29
+ /**
30
+ * Load children for a sitemap entry.
31
+ * This will fetch and load children if they haven't been loaded yet.
32
+ * @param entryId The ID of the entry to load children for.
33
+ * @returns Promise that resolves when children are loaded.
34
+ */
35
+ getChildren: (entryId: ID) => Promise<SitemapEntry[]>;
9
36
  /**
10
37
  * Get the current scope ID.
11
38
  * @returns The current scope ID.
@@ -26,4 +53,22 @@ export type SitemapSDK = {
26
53
  * @param options The view mode options.
27
54
  */
28
55
  addRequestViewMode: (options: RequestViewModeOptions) => void;
56
+ /**
57
+ * Add an indicator to a sitemap session.
58
+ * Indicators are displayed next to the entry name in the collections tree.
59
+ * @param entryId The ID of the entry to add the indicator to.
60
+ * @param indicator The indicator configuration.
61
+ * @returns A handle object with a `remove` method to remove the indicator.
62
+ * @example
63
+ *
64
+ * const indicator = sdk.sitemap.addEntryIndicator(entryId, {
65
+ * icon: "fas fa-exclamation-triangle",
66
+ * description: "Security warning",
67
+ * });
68
+ *
69
+ * // Later, remove the indicator
70
+ * indicator.remove();
71
+ *
72
+ */
73
+ addEntryIndicator: (entryId: ID, indicator: AddIndicatorOptions) => Indicator;
29
74
  };
@@ -0,0 +1,41 @@
1
+ import type { ID } from "./utils";
2
+ /**
3
+ * A automate session.
4
+ * @category Automate
5
+ */
6
+ export type AutomateSession = {
7
+ /**
8
+ * The ID of the session.
9
+ */
10
+ id: ID;
11
+ /**
12
+ * The name of the session.
13
+ */
14
+ name: string;
15
+ /**
16
+ * The date the session was created.
17
+ */
18
+ createdAt: Date;
19
+ /**
20
+ * The IDs of all entries in this session.
21
+ */
22
+ entryIds: ID[];
23
+ };
24
+ /**
25
+ * A automate entry.
26
+ * @category Automate
27
+ */
28
+ export type AutomateEntry = {
29
+ /**
30
+ * The ID of the entry.
31
+ */
32
+ id: ID;
33
+ /**
34
+ * The name of the entry.
35
+ */
36
+ name: string;
37
+ /**
38
+ * The date the entry was created.
39
+ */
40
+ createdAt: Date;
41
+ };
@@ -0,0 +1,87 @@
1
+ import { type ID } from "./utils";
2
+ /**
3
+ * An entry in sitemap.
4
+ * @category Sitemap
5
+ */
6
+ export type SitemapEntry = {
7
+ /**
8
+ * The ID of the entry.
9
+ */
10
+ id: ID;
11
+ /**
12
+ * The label of the entry.
13
+ */
14
+ label: string;
15
+ /**
16
+ * The kind of the entry.
17
+ */
18
+ kind: SitemapEntryKind;
19
+ /**
20
+ * The ID of the parent entry.
21
+ */
22
+ parentId?: ID;
23
+ /**
24
+ * The child state of the entry.
25
+ */
26
+ childState: ChildState;
27
+ };
28
+ export type SitemapRootEntry = {
29
+ /**
30
+ * The ID of the entry.
31
+ */
32
+ id: ID;
33
+ /**
34
+ * The label of the entry.
35
+ */
36
+ label: string;
37
+ /**
38
+ * The child state of the entry.
39
+ */
40
+ childState: ChildState;
41
+ };
42
+ /**
43
+ * The kind of a sitemap entry.
44
+ * @category Sitemap
45
+ */
46
+ export declare const SitemapEntryKind: {
47
+ readonly Directory: "DIRECTORY";
48
+ readonly Domain: "DOMAIN";
49
+ readonly Request: "REQUEST";
50
+ readonly RequestBody: "REQUEST_BODY";
51
+ readonly RequestQuery: "REQUEST_QUERY";
52
+ };
53
+ /**
54
+ * The kind of a sitemap entry.
55
+ * @category Sitemap
56
+ * @example
57
+ * ```ts
58
+ * const entry = {
59
+ * id: "123",
60
+ * label: "Example",
61
+ * kind: SitemapEntryKind.Request,
62
+ * };
63
+ * ```
64
+ */
65
+ export type SitemapEntryKind = (typeof SitemapEntryKind)[keyof typeof SitemapEntryKind];
66
+ export type ChildState = {
67
+ kind: "Empty";
68
+ } | {
69
+ kind: "NotLoaded";
70
+ } | {
71
+ kind: "Loaded";
72
+ items: ID[];
73
+ };
74
+ /**
75
+ * Event fired when the child state of a sitemap entry changes.
76
+ * @category Sitemap
77
+ */
78
+ export type SitemapEntryChildStateUpdateEvent = {
79
+ /**
80
+ * The ID of the entry that changed.
81
+ */
82
+ entryId: ID;
83
+ /**
84
+ * The new child state of the entry.
85
+ */
86
+ newChildState: ChildState;
87
+ };
@@ -60,3 +60,19 @@ export type Prettify<T> = {
60
60
  export type As<TType extends string> = {
61
61
  type: TType;
62
62
  };
63
+ /**
64
+ * Visual indicator displayed next to a item label in a tree component.
65
+ * Includes an icon and an associated description.
66
+ * @category Utils
67
+ */
68
+ export type AddIndicatorOptions = {
69
+ icon: Icon;
70
+ description: string;
71
+ };
72
+ /**
73
+ * Providing operations that can be performed on a item indicator.
74
+ * @category Utils
75
+ */
76
+ export type Indicator = {
77
+ remove: () => void;
78
+ };