@caido/sdk-frontend 0.42.1-beta.7 → 0.42.1-beta.9

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.
@@ -16,12 +16,14 @@ import type { SearchSDK } from "./search";
16
16
  import type { HTTPHistorySDK } from "./httpHistory";
17
17
  import type { FilesSDK } from "./files";
18
18
  import type { FiltersSDK } from "./filters";
19
+ import type { MatchReplaceSDK } from "./matchReplace";
19
20
  export type { CommandContext } from "./commands";
20
21
  export type { MenuItem } from "./menu";
21
22
  export type { ReplayTab, ReplaySession, ReplayCollection } from "./replay";
22
23
  export type { HostedFile } from "./files";
23
24
  export type { Filter } from "./filters";
24
25
  export type { HTTPQL, ID } from "./utils";
26
+ export type { MatchReplaceRule, MatchReplaceCollection, MatchReplaceStrategy, } from "./matchReplace";
25
27
  /**
26
28
  * Utilities for frontend plugins.
27
29
  * @category SDK
@@ -99,4 +101,8 @@ export type API<T extends BackendEndpoints = Record<string, never>, E extends Ba
99
101
  * Utilities to interact with Filters page.
100
102
  */
101
103
  filters: FiltersSDK;
104
+ /**
105
+ * Utilities to interact with Match and Replace page.
106
+ */
107
+ matchReplace: MatchReplaceSDK;
102
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
+ };