@buoy-gg/network 7.0.74 → 7.0.75
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/lib/commonjs/network/overrides/applyToFetch.js +1 -1
- package/lib/commonjs/network/overrides/engine.js +1 -1
- package/lib/commonjs/network/overrides/matchRule.js +1 -1
- package/lib/commonjs/network/overrides/overrideRulesStore.js +1 -1
- package/lib/commonjs/network/overrides/resolveOverride.js +1 -1
- package/lib/commonjs/network/sync/networkSyncAdapter.js +1 -1
- package/lib/commonjs/network/utils/networkListener.js +4 -4
- package/lib/module/network/overrides/applyToFetch.js +1 -1
- package/lib/module/network/overrides/engine.js +1 -1
- package/lib/module/network/overrides/matchRule.js +1 -1
- package/lib/module/network/overrides/overrideRulesStore.js +1 -1
- package/lib/module/network/overrides/resolveOverride.js +1 -1
- package/lib/module/network/sync/networkSyncAdapter.js +1 -1
- package/lib/module/network/utils/networkListener.js +4 -4
- package/lib/typescript/network/overrides/applyToFetch.d.ts +6 -0
- package/lib/typescript/network/overrides/engine.d.ts +11 -1
- package/lib/typescript/network/overrides/matchRule.d.ts +1 -1
- package/lib/typescript/network/overrides/overrideRulesStore.d.ts +21 -1
- package/lib/typescript/network/overrides/resolveOverride.d.ts +2 -2
- package/lib/typescript/network/overrides/types.d.ts +8 -0
- package/lib/typescript/network/sync/networkSyncAdapter.d.ts +29 -1
- package/lib/web/index.mjs +52 -52
- package/package.json +2 -2
|
@@ -137,6 +137,16 @@ declare class OverrideRulesStore {
|
|
|
137
137
|
upsertRule(draft: OverrideRuleDraft & {
|
|
138
138
|
id?: string;
|
|
139
139
|
}): OverrideRule | null;
|
|
140
|
+
/**
|
|
141
|
+
* Swap the whole list and the master switch in one write.
|
|
142
|
+
*
|
|
143
|
+
* For a tool that installs a rule SET and must later put the old one back
|
|
144
|
+
* exactly: bug links load a case's recorded answers this way, and undo it
|
|
145
|
+
* the same way. Order is kept, since first match wins. Device only: a
|
|
146
|
+
* mirror refuses (returns null), because the dashboard has no forwarder for
|
|
147
|
+
* a whole list.
|
|
148
|
+
*/
|
|
149
|
+
replaceAllRules(rules: readonly unknown[], enabled: boolean): OverrideRule[] | null;
|
|
140
150
|
updateRule(id: string, patch: Partial<OverrideRuleDraft>): void;
|
|
141
151
|
setRuleEnabled(id: string, enabled: boolean): void;
|
|
142
152
|
removeRule(id: string): void;
|
|
@@ -160,9 +170,19 @@ declare class OverrideRulesStore {
|
|
|
160
170
|
*
|
|
161
171
|
* Called at package import (see `preset.tsx`) rather than on first subscribe,
|
|
162
172
|
* because a rule has to fire from app boot — with the Network tool closed and
|
|
163
|
-
* nothing capturing.
|
|
173
|
+
* nothing capturing. On the web `loadNow` has usually done it already.
|
|
164
174
|
*/
|
|
165
175
|
ensureLoaded(): Promise<void>;
|
|
176
|
+
/**
|
|
177
|
+
* Web only: read the saved rules from localStorage right now.
|
|
178
|
+
*
|
|
179
|
+
* A page makes its first requests (the session check, the first queries)
|
|
180
|
+
* before an async read could finish, so a mocked sign-in was lost on every
|
|
181
|
+
* reload. localStorage is synchronous, so this puts the rules, and the
|
|
182
|
+
* interceptor that applies them, in place before the first request.
|
|
183
|
+
*/
|
|
184
|
+
loadNow(): void;
|
|
185
|
+
private hydrate;
|
|
166
186
|
/**
|
|
167
187
|
* Count this launch, and pause overrides if they've been armed and untouched
|
|
168
188
|
* for too many in a row. See MAX_UNTOUCHED_LAUNCHES for why.
|
|
@@ -28,7 +28,7 @@ export declare function shouldApply(rule: OverrideRule): boolean;
|
|
|
28
28
|
* its phase on the requests it deliberately skips — the caller needs the rule
|
|
29
29
|
* back even when the answer is "not this time".
|
|
30
30
|
*/
|
|
31
|
-
export declare function findMatchingRule(url: string, method: string, rules: readonly OverrideRule[], headers?: Record<string, string
|
|
31
|
+
export declare function findMatchingRule(url: string, method: string, rules: readonly OverrideRule[], headers?: Record<string, string>, body?: string): OverrideRule | null;
|
|
32
32
|
/**
|
|
33
33
|
* First ENABLED matching rule wins outright — no merging across rules.
|
|
34
34
|
*
|
|
@@ -41,6 +41,6 @@ export declare function findMatchingRule(url: string, method: string, rules: rea
|
|
|
41
41
|
* @param method HTTP method as the caller sent it (case-insensitive).
|
|
42
42
|
* @param rules Ordered rule list; earlier entries win.
|
|
43
43
|
*/
|
|
44
|
-
export declare function resolveOverride(url: string, method: string, rules: readonly OverrideRule[], headers?: Record<string, string
|
|
44
|
+
export declare function resolveOverride(url: string, method: string, rules: readonly OverrideRule[], headers?: Record<string, string>, body?: string): OverrideOutcome | null;
|
|
45
45
|
export { toOutcome };
|
|
46
46
|
//# sourceMappingURL=resolveOverride.d.ts.map
|
|
@@ -81,6 +81,14 @@ export interface OverrideRule {
|
|
|
81
81
|
* carried the token and never on the app's own token request.
|
|
82
82
|
*/
|
|
83
83
|
requireHeader?: string;
|
|
84
|
+
/**
|
|
85
|
+
* Only requests whose body CONTAINS this text. Absent means any body.
|
|
86
|
+
*
|
|
87
|
+
* For calls that share one URL, like GraphQL's `POST /graphql`: replaying a
|
|
88
|
+
* bug case needs the GetCart answer to reach GetCart, not whichever query
|
|
89
|
+
* asked first. A body that isn't text (FormData, a Blob) never matches.
|
|
90
|
+
*/
|
|
91
|
+
bodyIncludes?: string;
|
|
84
92
|
kind: OverrideRuleKind;
|
|
85
93
|
/** `respond` only. Clamped to [STATUS_MIN, STATUS_MAX]. Defaults to 200. */
|
|
86
94
|
status?: number;
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import type { OverrideRulesState } from "../overrides/overrideRulesStore";
|
|
2
|
-
import type
|
|
2
|
+
import { type OverrideRuleKind } from "../overrides/types";
|
|
3
3
|
import type { NetworkEvent } from "../types";
|
|
4
4
|
import { type EditViolation } from "@buoy-gg/shared-ui";
|
|
5
5
|
/**
|
|
@@ -208,6 +208,29 @@ export declare const networkSyncAdapter: {
|
|
|
208
208
|
clearOverrideRules: () => {
|
|
209
209
|
ok: boolean;
|
|
210
210
|
};
|
|
211
|
+
/**
|
|
212
|
+
* Replace every rule and the master switch at once, in order.
|
|
213
|
+
*
|
|
214
|
+
* For a tool that installs a whole rule set and must put the old one back
|
|
215
|
+
* exactly: bug links' sandbox (recorded answers, then block the rest) and
|
|
216
|
+
* its undo. Rules use the stored shape (`listOverrideRules` returns it).
|
|
217
|
+
*/
|
|
218
|
+
replaceOverrideRules: (params?: unknown) => Promise<{
|
|
219
|
+
ok: boolean;
|
|
220
|
+
error: string;
|
|
221
|
+
} | {
|
|
222
|
+
active: false;
|
|
223
|
+
inactiveReason: string;
|
|
224
|
+
ok: boolean;
|
|
225
|
+
count: number;
|
|
226
|
+
enabled: boolean;
|
|
227
|
+
error?: undefined;
|
|
228
|
+
} | {
|
|
229
|
+
ok: boolean;
|
|
230
|
+
count: number;
|
|
231
|
+
enabled: boolean;
|
|
232
|
+
error?: undefined;
|
|
233
|
+
}>;
|
|
211
234
|
/**
|
|
212
235
|
* Read the rules back — hit counts included, which the snapshot coalesces.
|
|
213
236
|
*
|
|
@@ -243,6 +266,10 @@ export declare const networkSyncAdapter: {
|
|
|
243
266
|
eventCount: number;
|
|
244
267
|
};
|
|
245
268
|
debugOverrides: (params?: unknown) => {
|
|
269
|
+
tested: {
|
|
270
|
+
url: string;
|
|
271
|
+
method: string;
|
|
272
|
+
};
|
|
246
273
|
interceptorInstalled: boolean;
|
|
247
274
|
listenerCount: number;
|
|
248
275
|
engine: {
|
|
@@ -253,6 +280,7 @@ export declare const networkSyncAdapter: {
|
|
|
253
280
|
};
|
|
254
281
|
store: {
|
|
255
282
|
enabled: boolean;
|
|
283
|
+
autoPaused: boolean;
|
|
256
284
|
ruleCount: number;
|
|
257
285
|
rulesVisibleToEngine: number;
|
|
258
286
|
};
|