@caido/sdk-frontend 0.42.1-beta.6 → 0.42.1-beta.8

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.42.1-beta.6",
3
+ "version": "0.42.1-beta.8",
4
4
  "description": "Typing for the Caido Frontend SDK",
5
5
  "author": "Caido Labs Inc. <dev@caido.io>",
6
6
  "license": "MIT",
@@ -0,0 +1,70 @@
1
+ import type { HTTPQL, ID } from "./utils";
2
+ /**
3
+ * SDK for interacting with the Filters page.
4
+ * @category Filters
5
+ */
6
+ export type FiltersSDK = {
7
+ /**
8
+ * Gets all filters.
9
+ * @returns The filters.
10
+ */
11
+ getAll: () => Filter[];
12
+ /**
13
+ * Creates a filter.
14
+ * @param options Options for the filter.
15
+ * @param options.name The name of the filter. Should be unique.
16
+ * @param options.query The HTTPQL query of the filter.
17
+ * @param options.alias The alias of the filter. Used when referencing the filter in an HTTPQL query (e.g. `preset:my-alias`).
18
+ *
19
+ * Should be unique and follow the format `[a-zA-Z0-9_-]+`.
20
+ *
21
+ * @returns The created filter.
22
+ */
23
+ create: (options: {
24
+ name: string;
25
+ query: HTTPQL;
26
+ alias: string;
27
+ }) => Promise<Filter>;
28
+ /**
29
+ * Updates a filter.
30
+ * @param id The ID of the filter to update.
31
+ * @param options Options for the filter.
32
+ * @param options.name The name of the filter.
33
+ * @param options.alias The alias of the filter.
34
+ * @param options.query The HTTPQL query of the filter.
35
+ * @returns The updated filter.
36
+ */
37
+ update: (id: ID, options: {
38
+ name: string;
39
+ alias: string;
40
+ query: HTTPQL;
41
+ }) => Promise<Filter>;
42
+ /**
43
+ * Deletes a filter.
44
+ * @param id The ID of the filter to delete.
45
+ */
46
+ delete: (id: ID) => Promise<void>;
47
+ };
48
+ /**
49
+ * Represents a filter.
50
+ * @category Filters
51
+ */
52
+ export type Filter = {
53
+ /**
54
+ * The ID of the filter.
55
+ */
56
+ id: ID;
57
+ /**
58
+ * The name of the filter.
59
+ */
60
+ name: string;
61
+ /**
62
+ * The alias of the filter.
63
+ * This alias is used when referencing the filter in an HTTPQL query (e.g. `preset:my-alias`).
64
+ */
65
+ alias: string;
66
+ /**
67
+ * The HTTPQL expression of the filter.
68
+ */
69
+ query: HTTPQL;
70
+ };
@@ -1,3 +1,4 @@
1
+ import type { HTTPQL } from "./utils";
1
2
  /**
2
3
  * Utilities to interact with the HTTP History page.
3
4
  * @category HTTP History
@@ -7,10 +8,10 @@ export type HTTPHistorySDK = {
7
8
  * Set the HTTPQL query that will be applied on the HTTP History table results.
8
9
  * @param query The HTTPQL query.
9
10
  */
10
- setQuery: (query: string) => void;
11
+ setQuery: (query: HTTPQL) => void;
11
12
  /**
12
13
  * Get the current HTTPQL query.
13
14
  * @returns The current HTTPQL query.
14
15
  */
15
- getQuery: () => string;
16
+ getQuery: () => HTTPQL;
16
17
  };
@@ -15,10 +15,15 @@ import type { ReplaySDK } from "./replay";
15
15
  import type { SearchSDK } from "./search";
16
16
  import type { HTTPHistorySDK } from "./httpHistory";
17
17
  import type { FilesSDK } from "./files";
18
+ import type { FiltersSDK } from "./filters";
19
+ import type { MatchReplaceSDK } from "./matchReplace";
18
20
  export type { CommandContext } from "./commands";
19
21
  export type { MenuItem } from "./menu";
20
22
  export type { ReplayTab, ReplaySession, ReplayCollection } from "./replay";
21
23
  export type { HostedFile } from "./files";
24
+ export type { Filter } from "./filters";
25
+ export type { HTTPQL, ID } from "./utils";
26
+ export type { MatchReplaceRule, MatchReplaceCollection, MatchReplaceStrategy, } from "./matchReplace";
22
27
  /**
23
28
  * Utilities for frontend plugins.
24
29
  * @category SDK
@@ -89,7 +94,15 @@ export type API<T extends BackendEndpoints = Record<string, never>, E extends Ba
89
94
  */
90
95
  httpHistory: HTTPHistorySDK;
91
96
  /**
92
- * Utilities to interact with files.
97
+ * Utilities to interact with the Files page.
93
98
  */
94
99
  files: FilesSDK;
100
+ /**
101
+ * Utilities to interact with Filters page.
102
+ */
103
+ filters: FiltersSDK;
104
+ /**
105
+ * Utilities to interact with Match and Replace page.
106
+ */
107
+ matchReplace: MatchReplaceSDK;
95
108
  };
@@ -0,0 +1,150 @@
1
+ import type { HTTPQL, ID } from "./utils";
2
+ /**
3
+ * Utilities to interact with the Match and Replace page.
4
+ * @category Match and Replace
5
+ */
6
+ export type MatchReplaceSDK = {
7
+ /**
8
+ * Get all collections.
9
+ */
10
+ getCollections: () => MatchReplaceCollection[];
11
+ /**
12
+ * Create a collection.
13
+ * @param options - The options for the collection.
14
+ * @param options.name - The name of the collection.
15
+ */
16
+ createCollection: (options: {
17
+ name: string;
18
+ }) => Promise<MatchReplaceCollection>;
19
+ /**
20
+ * Update a collection.
21
+ * @param id - The ID of the collection.
22
+ * @param options - The new values for the collection.
23
+ * @param options.name - The new name of the collection.
24
+ */
25
+ updateCollection: (id: ID, options: {
26
+ name: string;
27
+ }) => Promise<MatchReplaceCollection>;
28
+ /**
29
+ * Delete a collection.
30
+ * @param id - The ID of the collection.
31
+ */
32
+ deleteCollection: (id: ID) => Promise<void>;
33
+ /**
34
+ * Get all rules.
35
+ * @returns All rules.
36
+ */
37
+ getRules: () => MatchReplaceRule[];
38
+ /**
39
+ * Get all active rules.
40
+ * Rules are ordered in priority from highest to lowest.
41
+ * @returns All active rules.
42
+ */
43
+ getActiveRules: () => MatchReplaceRule[];
44
+ /**
45
+ * Select a rule to be displayed in the UI.
46
+ * @param id - The ID of the rule, or undefined to clear the selection.
47
+ */
48
+ selectRule: (id: ID | undefined) => void;
49
+ /**
50
+ * Create a rule.
51
+ * @param options - The options for the rule.
52
+ * @param options.name - The name of the rule.
53
+ * @param options.isEnabled - Whether the rule is enabled.
54
+ * @param options.matchTerm - The match term of the rule.
55
+ * @param options.replaceTerm - The replace term of the rule.
56
+ * @param options.isRegex - Whether the match term is a regex.
57
+ * @param options.strategy - The strategy of the rule.
58
+ * @param options.query - The HTTPQL query to match the rule against.
59
+ * @param options.collectionId - The ID of the collection the rule belongs to.
60
+ */
61
+ createRule: (options: {
62
+ name: string;
63
+ isEnabled: boolean;
64
+ matchTerm: string;
65
+ replaceTerm: string;
66
+ isRegex: boolean;
67
+ query: HTTPQL;
68
+ strategy: MatchReplaceStrategy;
69
+ collectionId: ID;
70
+ }) => Promise<MatchReplaceRule>;
71
+ /**
72
+ * Update a rule.
73
+ * @param id - The ID of the rule.
74
+ * @param options - The new values for the rule.
75
+ * @param options.name - The new name of the rule.
76
+ * @param options.isEnabled - Whether the rule is enabled.
77
+ * @param options.matchTerm - The new match term of the rule.
78
+ * @param options.replaceTerm - The new replace term of the rule.
79
+ * @param options.isRegex - Whether the match term is a regex.
80
+ * @param options.query - The new HTTPQL query of the rule.
81
+ * @param options.strategy - The new strategy of the rule.
82
+ */
83
+ updateRule: (id: ID, options: {
84
+ name: string;
85
+ isEnabled: boolean;
86
+ matchTerm: string;
87
+ replaceTerm: string;
88
+ isRegex: boolean;
89
+ query: HTTPQL;
90
+ strategy: MatchReplaceStrategy;
91
+ }) => Promise<MatchReplaceRule>;
92
+ /**
93
+ * Delete a rule.
94
+ * @param id - The ID of the rule.
95
+ */
96
+ deleteRule: (id: ID) => Promise<void>;
97
+ };
98
+ /**
99
+ * A rule in Match and Replace.
100
+ * @category Match and Replace
101
+ */
102
+ export type MatchReplaceRule = {
103
+ /**
104
+ * The ID of the rule.
105
+ */
106
+ id: ID;
107
+ /**
108
+ * The name of the rule.
109
+ */
110
+ name: string;
111
+ /**
112
+ * Whether the rule is enabled.
113
+ */
114
+ isEnabled: boolean;
115
+ /**
116
+ * The match term of the rule.
117
+ */
118
+ matchTerm: string;
119
+ /**
120
+ * The replace term of the rule.
121
+ */
122
+ replaceTerm: string;
123
+ /**
124
+ * Whether the match term is a regex.
125
+ */
126
+ isRegex: boolean;
127
+ /**
128
+ * The HTTPQL query to match the rule against.
129
+ * Only requests that match the query will be affected by the rule.
130
+ */
131
+ query: HTTPQL;
132
+ /**
133
+ * The strategy of the rule.
134
+ */
135
+ strategy: MatchReplaceStrategy;
136
+ /**
137
+ * The ID of the collection the rule belongs to.
138
+ */
139
+ collectionId: ID;
140
+ };
141
+ export type MatchReplaceStrategy = "REQUEST_FIRST_LINE" | "REQUEST_HEADER" | "REQUEST_BODY" | "RESPONSE_FIRST_LINE" | "RESPONSE_HEADER" | "RESPONSE_BODY";
142
+ /**
143
+ * A collection in Match and Replace.
144
+ * @category Match and Replace
145
+ */
146
+ export type MatchReplaceCollection = {
147
+ id: ID;
148
+ name: string;
149
+ ruleIds: ID[];
150
+ };
@@ -1,3 +1,4 @@
1
+ import type { ID } from "./utils";
1
2
  /**
2
3
  * A replay tab.
3
4
  * @category Replay
@@ -6,7 +7,7 @@ export type ReplayTab = {
6
7
  /**
7
8
  * The ID of the session associated with this tab.
8
9
  */
9
- sessionId: string;
10
+ sessionId: ID;
10
11
  };
11
12
  /**
12
13
  * A session in Replay.
@@ -16,7 +17,7 @@ export type ReplaySession = {
16
17
  /**
17
18
  * The ID of the session.
18
19
  */
19
- id: string;
20
+ id: ID;
20
21
  /**
21
22
  * The name of the session.
22
23
  */
@@ -24,7 +25,7 @@ export type ReplaySession = {
24
25
  /**
25
26
  * The ID of the collection the session belongs to.
26
27
  */
27
- collectionId: string;
28
+ collectionId: ID;
28
29
  };
29
30
  /**
30
31
  * A collection in Replay.
@@ -34,7 +35,7 @@ export type ReplayCollection = {
34
35
  /**
35
36
  * The ID of the collection.
36
37
  */
37
- id: string;
38
+ id: ID;
38
39
  /**
39
40
  * The name of the collection.
40
41
  */
@@ -42,7 +43,7 @@ export type ReplayCollection = {
42
43
  /**
43
44
  * The sessions in the collection.
44
45
  */
45
- sessionIds: string[];
46
+ sessionIds: ID[];
46
47
  };
47
48
  /**
48
49
  * Utilities to interact with Replay.
@@ -53,12 +54,12 @@ export type ReplaySDK = {
53
54
  * Open a replay tab for the given session.
54
55
  * @param sessionId The ID of the session to open.
55
56
  */
56
- openTab: (sessionId: string) => void;
57
+ openTab: (sessionId: ID) => void;
57
58
  /**
58
59
  * Close a replay tab for the given session.
59
60
  * @param sessionId The ID of the session to close.
60
61
  */
61
- closeTab: (sessionId: string) => void;
62
+ closeTab: (sessionId: ID) => void;
62
63
  /**
63
64
  * Get the list of all open replay tabs.
64
65
  * @returns The list of all open replay tabs.
@@ -80,5 +81,5 @@ export type ReplaySDK = {
80
81
  * @param name The new name of the session.
81
82
  * @returns The updated session.
82
83
  */
83
- renameSession: (id: string, name: string) => Promise<ReplaySession>;
84
+ renameSession: (id: ID, name: string) => Promise<ReplaySession>;
84
85
  };
@@ -1,3 +1,4 @@
1
+ import type { HTTPQL } from "./utils";
1
2
  /**
2
3
  * Utilities to interact with the Search page.
3
4
  * @category Search
@@ -7,10 +8,10 @@ export type SearchSDK = {
7
8
  * Set the HTTPQL query that will be applied on the search table results.
8
9
  * @param query The HTTPQL query.
9
10
  */
10
- setQuery: (query: string) => void;
11
+ setQuery: (query: HTTPQL) => void;
11
12
  /**
12
13
  * Get the current HTTPQL query.
13
14
  * @returns The current HTTPQL query.
14
15
  */
15
- getQuery: () => string;
16
+ getQuery: () => HTTPQL;
16
17
  };
@@ -12,6 +12,13 @@ export type ID = string & {
12
12
  export type CommandID = string & {
13
13
  __commandId?: never;
14
14
  };
15
+ /**
16
+ * An HTTPQL expression.
17
+ * @example `req.method.eq:"POST"`
18
+ */
19
+ export type HTTPQL = string & {
20
+ __httpql?: never;
21
+ };
15
22
  /**
16
23
  * A {@link https://fontawesome.com/icons|FontAwesome} icon class.
17
24
  * @example "fas fa-rocket"