@caido/sdk-frontend 0.54.2-beta.4 → 0.54.2-beta.6

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.4",
3
+ "version": "0.54.2-beta.6",
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/",
@@ -8,7 +8,7 @@ export type { SitemapEntry, SitemapRootEntry, ChildState, } from "./types/sitema
8
8
  export { SearchSlot, type SearchSlotContent } from "./types/search";
9
9
  export type { HostedFile } from "./types/files";
10
10
  export { FilterSlot, type Filter, type FilterSlotContent, type CurrentFilterChangeEvent, } from "./types/filter";
11
- export type { HTTPQL, ID, ComponentDefinition } from "./types/utils";
11
+ export type { HTTPQL, ID, ComponentDefinition, Selection } from "./types/utils";
12
12
  export type { JSONValue, JSONCompatible } from "./types/json";
13
13
  export type { SlotContent, ButtonSlotContent, CustomSlotContent, CommandSlotContent, } from "./types/slots";
14
14
  export type { RequestViewModeOptions, RequestFull, RequestDraft, RequestMeta, } from "./types/request";
@@ -26,3 +26,22 @@ export type { CommandPaletteView } from "./sdks/commandPalette";
26
26
  export type { LogSDK } from "./sdks/log";
27
27
  export type { API } from "./sdks";
28
28
  export { Routes } from "./types/navigation";
29
+ export { type GlobalContext, type PageContext } from "./types/window";
30
+ export type { AssistantPageContext } from "./types/assistant";
31
+ export type { AutomatePageContext } from "./types/automate";
32
+ export type { BackupsPageContext } from "./types/backups";
33
+ export type { CertificatePageContext } from "./types/certificate";
34
+ export type { EnvironmentPageContext } from "./types/environment";
35
+ export type { ExportsPageContext } from "./types/exports";
36
+ export type { FilesPageContext } from "./types/files";
37
+ export type { FilterPageContext } from "./types/filter";
38
+ export type { FindingsPageContext } from "./types/findings";
39
+ export type { HTTPHistoryPageContext } from "./types/httpHistory";
40
+ export type { InterceptPageContext } from "./types/intercept";
41
+ export type { ProjectsPageContext } from "./types/projects";
42
+ export type { ReplayPageContext } from "./types/replay";
43
+ export type { ScopePageContext } from "./types/scopes";
44
+ export type { SearchPageContext } from "./types/search";
45
+ export type { SitemapPageContext } from "./types/sitemap";
46
+ export type { MatchReplacePageContext } from "./types/matchReplace";
47
+ export type { WorkflowsPageContext } from "./types/workflows";
@@ -1,8 +1,8 @@
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
+ import type { AutomateEntry, AutomateSession } from "../types/automate";
4
3
  import type { RequestViewModeOptions } from "../types/request";
5
4
  import type { ResponseViewModeOptions } from "../types/response";
5
+ import type { AddIndicatorOptions, ID, Indicator } from "../types/utils";
6
6
  /**
7
7
  * Utilities to interact with the Automate page.
8
8
  * @category Automate
@@ -1,6 +1,6 @@
1
1
  import type { Editor } from "../types/editor";
2
- import type { ComponentDefinition } from "../types/utils";
3
- import { type Dialog, type DialogOptions } from "../types/window";
2
+ import type { ComponentDefinition, ListenerHandle } from "../types/utils";
3
+ import { type Dialog, type DialogOptions, type GlobalContext } from "../types/window";
4
4
  /**
5
5
  * Utilities to interact with the active page.
6
6
  * @category Window
@@ -35,4 +35,15 @@ export type WindowSDK = {
35
35
  * @returns A dialog object that can be used to close the dialog.
36
36
  */
37
37
  showDialog: (component: ComponentDefinition, options?: DialogOptions) => Dialog;
38
+ /**
39
+ * Get the current global context.
40
+ * @returns The current global context.
41
+ */
42
+ getContext: () => GlobalContext;
43
+ /**
44
+ * Subscribe to global context changes.
45
+ * @param callback The callback to call when the context changes.
46
+ * @returns An object with a `stop` method that can be called to stop listening to context changes.
47
+ */
48
+ onContextChange: (callback: (context: GlobalContext) => void) => ListenerHandle;
38
49
  };
@@ -0,0 +1,7 @@
1
+ /**
2
+ * Assistant page context.
3
+ * @category Assistant
4
+ */
5
+ export type AssistantPageContext = {
6
+ kind: "Assistant";
7
+ };
@@ -1,4 +1,4 @@
1
- import type { ID } from "./utils";
1
+ import { type ID, type Selection } from "./utils";
2
2
  /**
3
3
  * A automate session.
4
4
  * @category Automate
@@ -39,3 +39,18 @@ export type AutomateEntry = {
39
39
  */
40
40
  createdAt: Date;
41
41
  };
42
+ /**
43
+ * Automate page context.
44
+ * @category Automate
45
+ */
46
+ export type AutomatePageContext = {
47
+ kind: "Automate";
48
+ requestSelection: Selection<ID>;
49
+ selection: Selection<{
50
+ kind: "AutomateSession";
51
+ id: ID;
52
+ } | {
53
+ kind: "AutomateEntry";
54
+ id: ID;
55
+ }>;
56
+ };
@@ -0,0 +1,7 @@
1
+ /**
2
+ * Backups page context.
3
+ * @category Backups
4
+ */
5
+ export type BackupsPageContext = {
6
+ kind: "Backups";
7
+ };
@@ -0,0 +1,7 @@
1
+ /**
2
+ * Certificate page context.
3
+ * @category Certificate
4
+ */
5
+ export type CertificatePageContext = {
6
+ kind: "Certificate";
7
+ };
@@ -1,3 +1,4 @@
1
+ import { type ID, type Selection } from "./utils";
1
2
  /**
2
3
  * Represents an environment variable.
3
4
  * @category Environment
@@ -16,3 +17,11 @@ export type EnvironmentVariable = {
16
17
  */
17
18
  isSecret: boolean;
18
19
  };
20
+ /**
21
+ * Environment page context.
22
+ * @category Environment
23
+ */
24
+ export type EnvironmentPageContext = {
25
+ kind: "Environment";
26
+ selection: Selection<ID>;
27
+ };
@@ -0,0 +1,7 @@
1
+ /**
2
+ * Exports page context.
3
+ * @category Exports
4
+ */
5
+ export type ExportsPageContext = {
6
+ kind: "Exports";
7
+ };
@@ -32,3 +32,10 @@ export type HostedFile = {
32
32
  */
33
33
  updatedAt: Date;
34
34
  };
35
+ /**
36
+ * Files page context.
37
+ * @category Files
38
+ */
39
+ export type FilesPageContext = {
40
+ kind: "Files";
41
+ };
@@ -1,5 +1,5 @@
1
1
  import { type ButtonSlotContent, type CommandSlotContent, type CustomSlotContent } from "./slots";
2
- import { type HTTPQL, type ID } from "./utils";
2
+ import { type HTTPQL, type ID, type Selection } from "./utils";
3
3
  /**
4
4
  * Represents a filter.
5
5
  * @category Filters
@@ -56,3 +56,11 @@ export type CurrentFilterChangeEvent = {
56
56
  */
57
57
  filterId: ID | undefined;
58
58
  };
59
+ /**
60
+ * Filter page context.
61
+ * @category Filters
62
+ */
63
+ export type FilterPageContext = {
64
+ kind: "Filter";
65
+ selection: Selection<ID>;
66
+ };
@@ -1,4 +1,4 @@
1
- import { type ID } from "./utils";
1
+ import { type ID, type Selection } from "./utils";
2
2
  /**
3
3
  * Represents a {@link https://docs.caido.io/reference/features/logging/findings|Finding}.
4
4
  * @category Findings
@@ -29,3 +29,11 @@ export type Finding = {
29
29
  */
30
30
  path: string;
31
31
  };
32
+ /**
33
+ * Findings page context.
34
+ * @category Findings
35
+ */
36
+ export type FindingsPageContext = {
37
+ kind: "Findings";
38
+ selection: Selection<ID>;
39
+ };
@@ -1,4 +1,5 @@
1
1
  import { type ButtonSlotContent, type CommandSlotContent, type CustomSlotContent } from "./slots";
2
+ import { type ID, type Selection } from "./utils";
2
3
  /**
3
4
  * The slots in the HTTP History UI.
4
5
  * @category HTTP History
@@ -13,3 +14,11 @@ export type HTTPHistorySlot = (typeof HTTPHistorySlot)[keyof typeof HTTPHistoryS
13
14
  export type HTTPHistorySlotContent = {
14
15
  [HTTPHistorySlot.ToolbarPrimary]: ButtonSlotContent | CustomSlotContent | CommandSlotContent;
15
16
  };
17
+ /**
18
+ * HTTP history page context.
19
+ * @category HTTP History
20
+ */
21
+ export type HTTPHistoryPageContext = {
22
+ kind: "HTTPHistory";
23
+ selection: Selection<ID>;
24
+ };
@@ -0,0 +1,19 @@
1
+ import { type Selection } from "./utils";
2
+ /**
3
+ * A unique intercept message identifier.
4
+ * @category Intercept
5
+ */
6
+ type InterceptMessageId = string & {
7
+ __interceptMessageId?: never;
8
+ };
9
+ /**
10
+ * Intercept page context.
11
+ * @category Intercept
12
+ */
13
+ export type InterceptPageContext = {
14
+ kind: "Intercept";
15
+ requestSelection: Selection<InterceptMessageId>;
16
+ responseSelection: Selection<InterceptMessageId>;
17
+ websocketSelection: Selection<InterceptMessageId>;
18
+ };
19
+ export {};
@@ -1,5 +1,5 @@
1
1
  import { type ButtonSlotContent, type CommandSlotContent, type CustomSlotContent } from "./slots";
2
- import { type HTTPQL, type ID } from "./utils";
2
+ import { type HTTPQL, type ID, type Selection } from "./utils";
3
3
  /**
4
4
  * A rule in Match and Replace.
5
5
  * @category Match and Replace
@@ -432,4 +432,12 @@ export type CurrentMatchReplaceRuleChangeEvent = {
432
432
  */
433
433
  ruleId: ID | undefined;
434
434
  };
435
+ /**
436
+ * Match and Replace page context.
437
+ * @category Match and Replace
438
+ */
439
+ export type MatchReplacePageContext = {
440
+ kind: "MatchReplace";
441
+ selection: Selection<ID>;
442
+ };
435
443
  export {};
@@ -6,3 +6,10 @@ import { type ID } from "./utils";
6
6
  export type SelectedProjectChangeEvent = {
7
7
  projectId: ID | undefined;
8
8
  };
9
+ /**
10
+ * Projects page context.
11
+ * @category Projects
12
+ */
13
+ export type ProjectsPageContext = {
14
+ kind: "Projects";
15
+ };
@@ -1,5 +1,5 @@
1
1
  import { type ButtonSlotContent, type CommandSlotContent, type CustomSlotContent } from "./slots";
2
- import { type ID } from "./utils";
2
+ import { type ID, type Selection } from "./utils";
3
3
  /**
4
4
  * The slots in the Replay UI.
5
5
  * @category Replay
@@ -218,3 +218,19 @@ export type ReplayCollectionCreatedEvent = {
218
218
  */
219
219
  collection: ReplayCollection;
220
220
  };
221
+ /**
222
+ * Replay page context.
223
+ * @category Replay
224
+ */
225
+ export type ReplayPageContext = {
226
+ kind: "Replay";
227
+ selection: Selection<ReplaySessionId>;
228
+ };
229
+ /**
230
+ * A unique replay session identifier.
231
+ * @category Replay
232
+ */
233
+ type ReplaySessionId = string & {
234
+ __replaySessionId?: never;
235
+ };
236
+ export {};
@@ -1,5 +1,5 @@
1
1
  import { type ButtonSlotContent, type CommandSlotContent, type CustomSlotContent } from "./slots";
2
- import { type ID } from "./utils";
2
+ import { type ID, type Selection } from "./utils";
3
3
  /**
4
4
  * Represents a scope.
5
5
  * @category Scopes
@@ -51,3 +51,11 @@ export type CurrentScopeChangeEvent = {
51
51
  */
52
52
  scopeId: ID | undefined;
53
53
  };
54
+ /**
55
+ * Scope page context.
56
+ * @category Scopes
57
+ */
58
+ export type ScopePageContext = {
59
+ kind: "Scope";
60
+ selection: Selection<ID>;
61
+ };
@@ -13,3 +13,10 @@ export type SearchSlot = (typeof SearchSlot)[keyof typeof SearchSlot];
13
13
  export type SearchSlotContent = {
14
14
  [SearchSlot.ToolbarPrimary]: ButtonSlotContent | CustomSlotContent | CommandSlotContent;
15
15
  };
16
+ /**
17
+ * Search page context.
18
+ * @category Search
19
+ */
20
+ export type SearchPageContext = {
21
+ kind: "Search";
22
+ };
@@ -1,4 +1,4 @@
1
- import { type ID } from "./utils";
1
+ import { type ID, type Selection } from "./utils";
2
2
  /**
3
3
  * An entry in sitemap.
4
4
  * @category Sitemap
@@ -85,3 +85,12 @@ export type SitemapEntryChildStateUpdateEvent = {
85
85
  */
86
86
  newChildState: ChildState;
87
87
  };
88
+ /**
89
+ * Sitemap page context.
90
+ * @category Sitemap
91
+ */
92
+ export type SitemapPageContext = {
93
+ kind: "Sitemap";
94
+ entrySelection: Selection<ID>;
95
+ requestSelection: Selection<ID>;
96
+ };
@@ -60,6 +60,18 @@ export type Prettify<T> = {
60
60
  export type As<TType extends string> = {
61
61
  type: TType;
62
62
  };
63
+ /**
64
+ * Generic selection type with main and secondary items.
65
+ * Main represents the primary selected item, secondary represents additional selected items.
66
+ * @category Utils
67
+ */
68
+ export type Selection<TId> = {
69
+ kind: "Empty";
70
+ } | {
71
+ kind: "Selected";
72
+ main: TId;
73
+ secondary: TId[];
74
+ };
63
75
  /**
64
76
  * Visual indicator displayed next to a item label in a tree component.
65
77
  * Includes an icon and an associated description.
@@ -0,0 +1,7 @@
1
+ /**
2
+ * Certificate page context.
3
+ * @category Websockets
4
+ */
5
+ export type WebsocketPageContext = {
6
+ kind: "Websocket";
7
+ };
@@ -1,3 +1,22 @@
1
+ import type { AssistantPageContext } from "./assistant";
2
+ import type { AutomatePageContext } from "./automate";
3
+ import type { BackupsPageContext } from "./backups";
4
+ import type { CertificatePageContext } from "./certificate";
5
+ import type { EnvironmentPageContext } from "./environment";
6
+ import type { ExportsPageContext } from "./exports";
7
+ import type { FilesPageContext } from "./files";
8
+ import type { FilterPageContext } from "./filter";
9
+ import type { FindingsPageContext } from "./findings";
10
+ import type { HTTPHistoryPageContext } from "./httpHistory";
11
+ import type { InterceptPageContext } from "./intercept";
12
+ import type { MatchReplacePageContext } from "./matchReplace";
13
+ import type { ProjectsPageContext } from "./projects";
14
+ import type { ReplayPageContext } from "./replay";
15
+ import type { ScopePageContext } from "./scopes";
16
+ import type { SearchPageContext } from "./search";
17
+ import type { SitemapPageContext } from "./sitemap";
18
+ import { type WebsocketPageContext } from "./websocket";
19
+ import type { WorkflowsPageContext } from "./workflows";
1
20
  /**
2
21
  * Options for configuring a dialog.
3
22
  * @category Window
@@ -17,3 +36,15 @@ export type DialogOptions = {
17
36
  export type Dialog = {
18
37
  close: () => void;
19
38
  };
39
+ /**
40
+ * Represents the context of the current page.
41
+ * @category Window
42
+ */
43
+ export type PageContext = AssistantPageContext | AutomatePageContext | BackupsPageContext | CertificatePageContext | ExportsPageContext | EnvironmentPageContext | FilterPageContext | FindingsPageContext | HTTPHistoryPageContext | ReplayPageContext | ScopePageContext | SearchPageContext | WorkflowsPageContext | ProjectsPageContext | FilesPageContext | MatchReplacePageContext | InterceptPageContext | SitemapPageContext | WebsocketPageContext;
44
+ /**
45
+ * Represents the global context of the application.
46
+ * @category Window
47
+ */
48
+ export type GlobalContext = {
49
+ page?: PageContext;
50
+ };
@@ -35,3 +35,10 @@ export type OnUpdatedWorkflowCallback = (event: {
35
35
  export type OnDeletedWorkflowCallback = (event: {
36
36
  id: ID;
37
37
  }) => void;
38
+ /**
39
+ * Workflows page context.
40
+ * @category Workflows
41
+ */
42
+ export type WorkflowsPageContext = {
43
+ kind: "Workflows";
44
+ };