@buoy-gg/network 7.0.40 → 7.0.42
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/README.md +11 -79
- package/lib/commonjs/index.js +1 -325
- package/lib/commonjs/index.web.js +1 -420
- package/lib/commonjs/network/components/DataViewer.web.js +1 -879
- package/lib/commonjs/network/components/NetworkCopyScreen.web.js +1 -48
- package/lib/commonjs/network/components/NetworkCopySettingsView.js +27 -755
- package/lib/commonjs/network/components/NetworkCopySettingsView.web.js +14 -1242
- package/lib/commonjs/network/components/NetworkDetailScreen.web.js +1 -101
- package/lib/commonjs/network/components/NetworkDetailStepper.js +1 -108
- package/lib/commonjs/network/components/NetworkDetailStepper.web.js +1 -298
- package/lib/commonjs/network/components/NetworkEventDetailView.js +15 -1130
- package/lib/commonjs/network/components/NetworkEventDetailView.web.js +15 -1484
- package/lib/commonjs/network/components/NetworkEventItemCompact.js +2 -401
- package/lib/commonjs/network/components/NetworkEventItemCompact.web.js +2 -820
- package/lib/commonjs/network/components/NetworkFilterScreen.web.js +1 -55
- package/lib/commonjs/network/components/NetworkFilterViewV3.js +1 -442
- package/lib/commonjs/network/components/NetworkFilterViewV3.web.js +1 -1310
- package/lib/commonjs/network/components/NetworkHeaderLive.js +1 -375
- package/lib/commonjs/network/components/NetworkHeaderLive.web.js +1 -623
- package/lib/commonjs/network/components/NetworkHeaderMenu.js +1 -190
- package/lib/commonjs/network/components/NetworkListScreen.js +1 -404
- package/lib/commonjs/network/components/NetworkListScreen.web.js +1 -625
- package/lib/commonjs/network/components/NetworkModal.js +1 -786
- package/lib/commonjs/network/components/NetworkNumberPrompt.js +1 -178
- package/lib/commonjs/network/components/NetworkNumberPrompt.web.js +1 -232
- package/lib/commonjs/network/components/NetworkOverrideEditor.js +1 -814
- package/lib/commonjs/network/components/NetworkOverrideEditor.web.js +1 -942
- package/lib/commonjs/network/components/NetworkOverrideHeaderButton.js +1 -107
- package/lib/commonjs/network/components/NetworkOverrideHeaderButton.web.js +1 -133
- package/lib/commonjs/network/components/NetworkOverridesButton.js +1 -90
- package/lib/commonjs/network/components/NetworkOverridesButton.web.js +1 -143
- package/lib/commonjs/network/components/NetworkOverridesScreen.js +1 -543
- package/lib/commonjs/network/components/NetworkOverridesScreen.web.js +1 -830
- package/lib/commonjs/network/components/NetworkSavedScreen.js +1 -226
- package/lib/commonjs/network/components/NetworkSavedScreen.web.js +1 -463
- package/lib/commonjs/network/components/NetworkUpgradeBanner.js +1 -76
- package/lib/commonjs/network/components/response-editor/Explorer.js +1 -973
- package/lib/commonjs/network/components/response-editor/Explorer.web.js +1 -1136
- package/lib/commonjs/network/components/response-editor/deleteNestedDataByPath.js +1 -56
- package/lib/commonjs/network/components/response-editor/editorContext.js +1 -33
- package/lib/commonjs/network/components/response-editor/updateNestedDataByPath.js +1 -61
- package/lib/commonjs/network/conditions/NetworkConditionsControl.js +1 -235
- package/lib/commonjs/network/conditions/NetworkConditionsControl.test.js +1 -136
- package/lib/commonjs/network/conditions/NetworkConditionsIcon.js +1 -33
- package/lib/commonjs/network/conditions/NetworkFloatingTool.js +1 -310
- package/lib/commonjs/network/conditions/NetworkFloatingTool.test.js +1 -219
- package/lib/commonjs/network/conditions/store.js +1 -75
- package/lib/commonjs/network/conditions/wait.js +1 -43
- package/lib/commonjs/network/conditions/xhr.js +1 -110
- package/lib/commonjs/network/hooks/useLiveNetworkEvent.js +1 -62
- package/lib/commonjs/network/hooks/useNetworkBadgeCounts.js +1 -83
- package/lib/commonjs/network/hooks/useNetworkEventList.js +1 -108
- package/lib/commonjs/network/hooks/useNetworkEvents.js +1 -318
- package/lib/commonjs/network/hooks/useNetworkHasMatches.js +1 -56
- package/lib/commonjs/network/hooks/useNetworkSaved.js +1 -38
- package/lib/commonjs/network/hooks/useNetworkSelection.js +1 -53
- package/lib/commonjs/network/hooks/useOverrideRules.js +1 -36
- package/lib/commonjs/network/hooks/useTickEveryMinute.js +1 -21
- package/lib/commonjs/network/overrides/applyToFetch.js +1 -80
- package/lib/commonjs/network/overrides/applyToXhr.js +2 -453
- package/lib/commonjs/network/overrides/engine.js +1 -93
- package/lib/commonjs/network/overrides/matchRule.js +1 -81
- package/lib/commonjs/network/overrides/overriddenRows.js +1 -0
- package/lib/commonjs/network/overrides/overrideRulesStore.js +1 -550
- package/lib/commonjs/network/overrides/presets.js +1 -70
- package/lib/commonjs/network/overrides/resolveOverride.js +1 -158
- package/lib/commonjs/network/overrides/types.js +1 -90
- package/lib/commonjs/network/sync/networkBodyResolver.js +1 -39
- package/lib/commonjs/network/sync/networkSyncAdapter.js +1 -882
- package/lib/commonjs/network/sync/overrideHonesty.release.test.js +1 -36
- package/lib/commonjs/network/types/index.js +1 -5
- package/lib/commonjs/network/utils/extractOperationName.js +1 -80
- package/lib/commonjs/network/utils/filterNetworkEvents.js +1 -96
- package/lib/commonjs/network/utils/formatGraphQLVariables.js +1 -219
- package/lib/commonjs/network/utils/formatting.js +1 -30
- package/lib/commonjs/network/utils/generateCurl.js +2 -71
- package/lib/commonjs/network/utils/generateNetworkCopyText.js +37 -166
- package/lib/commonjs/network/utils/httpCompletion.js +1 -37
- package/lib/commonjs/network/utils/networkEventStore.js +1 -393
- package/lib/commonjs/network/utils/networkListener.js +4 -1259
- package/lib/commonjs/network/utils/networkSavedStore.js +3 -577
- package/lib/commonjs/network/utils/networkSelectionStore.js +1 -193
- package/lib/commonjs/network/utils/realNow.js +1 -0
- package/lib/commonjs/network/utils/requestId.js +1 -0
- package/lib/commonjs/network/utils/resolveRequestUrl.js +1 -0
- package/lib/commonjs/network/utils/selectSavedEvents.js +1 -39
- package/lib/commonjs/network/utils/startNetworkCapture.js +1 -0
- package/lib/commonjs/network/utils/withPinnedFirst.js +1 -32
- package/lib/commonjs/preset.js +1 -102
- package/lib/module/index.js +1 -103
- package/lib/module/index.web.js +1 -82
- package/lib/module/network/components/DataViewer.web.js +1 -875
- package/lib/module/network/components/NetworkCopyScreen.web.js +1 -44
- package/lib/module/network/components/NetworkCopySettingsView.js +27 -750
- package/lib/module/network/components/NetworkCopySettingsView.web.js +14 -1237
- package/lib/module/network/components/NetworkDetailScreen.web.js +1 -97
- package/lib/module/network/components/NetworkDetailStepper.js +1 -104
- package/lib/module/network/components/NetworkDetailStepper.web.js +1 -296
- package/lib/module/network/components/NetworkEventDetailView.js +15 -1129
- package/lib/module/network/components/NetworkEventDetailView.web.js +15 -1482
- package/lib/module/network/components/NetworkEventItemCompact.js +2 -398
- package/lib/module/network/components/NetworkEventItemCompact.web.js +2 -818
- package/lib/module/network/components/NetworkFilterScreen.web.js +1 -51
- package/lib/module/network/components/NetworkFilterViewV3.js +1 -438
- package/lib/module/network/components/NetworkFilterViewV3.web.js +1 -1306
- package/lib/module/network/components/NetworkHeaderLive.js +1 -366
- package/lib/module/network/components/NetworkHeaderLive.web.js +1 -617
- package/lib/module/network/components/NetworkHeaderMenu.js +1 -184
- package/lib/module/network/components/NetworkListScreen.js +1 -400
- package/lib/module/network/components/NetworkListScreen.web.js +1 -623
- package/lib/module/network/components/NetworkModal.js +1 -781
- package/lib/module/network/components/NetworkNumberPrompt.js +1 -174
- package/lib/module/network/components/NetworkNumberPrompt.web.js +1 -230
- package/lib/module/network/components/NetworkOverrideEditor.js +1 -811
- package/lib/module/network/components/NetworkOverrideEditor.web.js +1 -939
- package/lib/module/network/components/NetworkOverrideHeaderButton.js +1 -104
- package/lib/module/network/components/NetworkOverrideHeaderButton.web.js +1 -131
- package/lib/module/network/components/NetworkOverridesButton.js +1 -87
- package/lib/module/network/components/NetworkOverridesButton.web.js +1 -141
- package/lib/module/network/components/NetworkOverridesScreen.js +1 -539
- package/lib/module/network/components/NetworkOverridesScreen.web.js +1 -826
- package/lib/module/network/components/NetworkSavedScreen.js +1 -222
- package/lib/module/network/components/NetworkSavedScreen.web.js +1 -461
- package/lib/module/network/components/NetworkUpgradeBanner.js +1 -72
- package/lib/module/network/components/response-editor/Explorer.js +1 -972
- package/lib/module/network/components/response-editor/Explorer.web.js +1 -1133
- package/lib/module/network/components/response-editor/deleteNestedDataByPath.js +1 -51
- package/lib/module/network/components/response-editor/editorContext.js +1 -29
- package/lib/module/network/components/response-editor/updateNestedDataByPath.js +1 -56
- package/lib/module/network/conditions/NetworkConditionsControl.js +1 -231
- package/lib/module/network/conditions/NetworkConditionsControl.test.js +1 -135
- package/lib/module/network/conditions/NetworkConditionsIcon.js +1 -29
- package/lib/module/network/conditions/NetworkFloatingTool.js +1 -304
- package/lib/module/network/conditions/NetworkFloatingTool.test.js +1 -218
- package/lib/module/network/conditions/store.js +1 -65
- package/lib/module/network/conditions/wait.js +1 -38
- package/lib/module/network/conditions/xhr.js +1 -106
- package/lib/module/network/hooks/useLiveNetworkEvent.js +1 -58
- package/lib/module/network/hooks/useNetworkBadgeCounts.js +1 -79
- package/lib/module/network/hooks/useNetworkEventList.js +1 -104
- package/lib/module/network/hooks/useNetworkEvents.js +1 -314
- package/lib/module/network/hooks/useNetworkHasMatches.js +1 -52
- package/lib/module/network/hooks/useNetworkSaved.js +1 -34
- package/lib/module/network/hooks/useNetworkSelection.js +1 -46
- package/lib/module/network/hooks/useOverrideRules.js +1 -32
- package/lib/module/network/hooks/useTickEveryMinute.js +1 -11
- package/lib/module/network/overrides/applyToFetch.js +1 -72
- package/lib/module/network/overrides/applyToXhr.js +2 -446
- package/lib/module/network/overrides/engine.js +1 -85
- package/lib/module/network/overrides/matchRule.js +1 -75
- package/lib/module/network/overrides/overriddenRows.js +1 -0
- package/lib/module/network/overrides/overrideRulesStore.js +1 -547
- package/lib/module/network/overrides/presets.js +1 -65
- package/lib/module/network/overrides/resolveOverride.js +1 -152
- package/lib/module/network/overrides/types.js +1 -86
- package/lib/module/network/sync/networkBodyResolver.js +1 -34
- package/lib/module/network/sync/networkSyncAdapter.js +1 -880
- package/lib/module/network/sync/overrideHonesty.release.test.js +1 -35
- package/lib/module/network/types/index.js +1 -3
- package/lib/module/network/utils/extractOperationName.js +1 -76
- package/lib/module/network/utils/filterNetworkEvents.js +1 -92
- package/lib/module/network/utils/formatGraphQLVariables.js +1 -213
- package/lib/module/network/utils/formatting.js +1 -9
- package/lib/module/network/utils/generateCurl.js +2 -67
- package/lib/module/network/utils/generateNetworkCopyText.js +37 -162
- package/lib/module/network/utils/httpCompletion.js +1 -32
- package/lib/module/network/utils/networkEventStore.js +1 -391
- package/lib/module/network/utils/networkListener.js +4 -1249
- package/lib/module/network/utils/networkSavedStore.js +3 -572
- package/lib/module/network/utils/networkSelectionStore.js +1 -188
- package/lib/module/network/utils/realNow.js +1 -0
- package/lib/module/network/utils/requestId.js +1 -0
- package/lib/module/network/utils/resolveRequestUrl.js +1 -0
- package/lib/module/network/utils/selectSavedEvents.js +1 -35
- package/lib/module/network/utils/startNetworkCapture.js +1 -0
- package/lib/module/network/utils/withPinnedFirst.js +1 -28
- package/lib/module/preset.js +1 -100
- package/lib/typescript/index.d.ts +1 -0
- package/lib/typescript/network/overrides/applyToXhr.d.ts +1 -0
- package/lib/typescript/network/overrides/engine.d.ts +1 -1
- package/lib/typescript/network/overrides/matchRule.d.ts +1 -1
- package/lib/typescript/network/overrides/overriddenRows.d.ts +16 -0
- package/lib/typescript/network/overrides/resolveOverride.d.ts +2 -2
- package/lib/typescript/network/overrides/types.d.ts +9 -0
- package/lib/typescript/network/utils/networkListener.d.ts +14 -4
- package/lib/typescript/network/utils/networkSavedStore.d.ts +4 -4
- package/lib/typescript/network/utils/realNow.d.ts +18 -0
- package/lib/typescript/network/utils/requestId.d.ts +2 -0
- package/lib/typescript/network/utils/resolveRequestUrl.d.ts +3 -0
- package/lib/typescript/network/utils/startNetworkCapture.d.ts +6 -0
- package/lib/web/index.mjs +145 -0
- package/package.json +32 -10
- package/lib/typescript/index.d.ts.map +0 -1
- package/lib/typescript/index.web.d.ts.map +0 -1
- package/lib/typescript/network/components/DataViewer.web.d.ts.map +0 -1
- package/lib/typescript/network/components/NetworkCopyScreen.web.d.ts.map +0 -1
- package/lib/typescript/network/components/NetworkCopySettingsView.d.ts.map +0 -1
- package/lib/typescript/network/components/NetworkCopySettingsView.web.d.ts.map +0 -1
- package/lib/typescript/network/components/NetworkDetailScreen.web.d.ts.map +0 -1
- package/lib/typescript/network/components/NetworkDetailStepper.d.ts.map +0 -1
- package/lib/typescript/network/components/NetworkDetailStepper.web.d.ts.map +0 -1
- package/lib/typescript/network/components/NetworkEventDetailView.d.ts.map +0 -1
- package/lib/typescript/network/components/NetworkEventDetailView.web.d.ts.map +0 -1
- package/lib/typescript/network/components/NetworkEventItemCompact.d.ts.map +0 -1
- package/lib/typescript/network/components/NetworkEventItemCompact.web.d.ts.map +0 -1
- package/lib/typescript/network/components/NetworkFilterScreen.web.d.ts.map +0 -1
- package/lib/typescript/network/components/NetworkFilterViewV3.d.ts.map +0 -1
- package/lib/typescript/network/components/NetworkFilterViewV3.web.d.ts.map +0 -1
- package/lib/typescript/network/components/NetworkHeaderLive.d.ts.map +0 -1
- package/lib/typescript/network/components/NetworkHeaderLive.web.d.ts.map +0 -1
- package/lib/typescript/network/components/NetworkHeaderMenu.d.ts.map +0 -1
- package/lib/typescript/network/components/NetworkListScreen.d.ts.map +0 -1
- package/lib/typescript/network/components/NetworkListScreen.web.d.ts.map +0 -1
- package/lib/typescript/network/components/NetworkModal.d.ts.map +0 -1
- package/lib/typescript/network/components/NetworkNumberPrompt.d.ts.map +0 -1
- package/lib/typescript/network/components/NetworkNumberPrompt.web.d.ts.map +0 -1
- package/lib/typescript/network/components/NetworkOverrideEditor.d.ts.map +0 -1
- package/lib/typescript/network/components/NetworkOverrideEditor.web.d.ts.map +0 -1
- package/lib/typescript/network/components/NetworkOverrideHeaderButton.d.ts.map +0 -1
- package/lib/typescript/network/components/NetworkOverrideHeaderButton.web.d.ts.map +0 -1
- package/lib/typescript/network/components/NetworkOverridesButton.d.ts.map +0 -1
- package/lib/typescript/network/components/NetworkOverridesButton.web.d.ts.map +0 -1
- package/lib/typescript/network/components/NetworkOverridesScreen.d.ts.map +0 -1
- package/lib/typescript/network/components/NetworkOverridesScreen.web.d.ts.map +0 -1
- package/lib/typescript/network/components/NetworkSavedScreen.d.ts.map +0 -1
- package/lib/typescript/network/components/NetworkSavedScreen.web.d.ts.map +0 -1
- package/lib/typescript/network/components/NetworkUpgradeBanner.d.ts.map +0 -1
- package/lib/typescript/network/components/response-editor/Explorer.d.ts.map +0 -1
- package/lib/typescript/network/components/response-editor/Explorer.web.d.ts.map +0 -1
- package/lib/typescript/network/components/response-editor/deleteNestedDataByPath.d.ts.map +0 -1
- package/lib/typescript/network/components/response-editor/editorContext.d.ts.map +0 -1
- package/lib/typescript/network/components/response-editor/updateNestedDataByPath.d.ts.map +0 -1
- package/lib/typescript/network/conditions/NetworkConditionsControl.d.ts.map +0 -1
- package/lib/typescript/network/conditions/NetworkConditionsControl.test.d.ts.map +0 -1
- package/lib/typescript/network/conditions/NetworkConditionsIcon.d.ts.map +0 -1
- package/lib/typescript/network/conditions/NetworkFloatingTool.d.ts.map +0 -1
- package/lib/typescript/network/conditions/NetworkFloatingTool.test.d.ts.map +0 -1
- package/lib/typescript/network/conditions/store.d.ts.map +0 -1
- package/lib/typescript/network/conditions/wait.d.ts.map +0 -1
- package/lib/typescript/network/conditions/xhr.d.ts.map +0 -1
- package/lib/typescript/network/hooks/useLiveNetworkEvent.d.ts.map +0 -1
- package/lib/typescript/network/hooks/useNetworkBadgeCounts.d.ts.map +0 -1
- package/lib/typescript/network/hooks/useNetworkEventList.d.ts.map +0 -1
- package/lib/typescript/network/hooks/useNetworkEvents.d.ts.map +0 -1
- package/lib/typescript/network/hooks/useNetworkHasMatches.d.ts.map +0 -1
- package/lib/typescript/network/hooks/useNetworkSaved.d.ts.map +0 -1
- package/lib/typescript/network/hooks/useNetworkSelection.d.ts.map +0 -1
- package/lib/typescript/network/hooks/useOverrideRules.d.ts.map +0 -1
- package/lib/typescript/network/hooks/useTickEveryMinute.d.ts.map +0 -1
- package/lib/typescript/network/overrides/applyToFetch.d.ts.map +0 -1
- package/lib/typescript/network/overrides/applyToXhr.d.ts.map +0 -1
- package/lib/typescript/network/overrides/engine.d.ts.map +0 -1
- package/lib/typescript/network/overrides/matchRule.d.ts.map +0 -1
- package/lib/typescript/network/overrides/overrideRulesStore.d.ts.map +0 -1
- package/lib/typescript/network/overrides/presets.d.ts.map +0 -1
- package/lib/typescript/network/overrides/resolveOverride.d.ts.map +0 -1
- package/lib/typescript/network/overrides/types.d.ts.map +0 -1
- package/lib/typescript/network/sync/networkBodyResolver.d.ts.map +0 -1
- package/lib/typescript/network/sync/networkSyncAdapter.d.ts.map +0 -1
- package/lib/typescript/network/sync/overrideHonesty.release.test.d.ts.map +0 -1
- package/lib/typescript/network/types/index.d.ts.map +0 -1
- package/lib/typescript/network/utils/extractOperationName.d.ts.map +0 -1
- package/lib/typescript/network/utils/filterNetworkEvents.d.ts.map +0 -1
- package/lib/typescript/network/utils/formatGraphQLVariables.d.ts.map +0 -1
- package/lib/typescript/network/utils/formatting.d.ts.map +0 -1
- package/lib/typescript/network/utils/generateCurl.d.ts.map +0 -1
- package/lib/typescript/network/utils/generateNetworkCopyText.d.ts.map +0 -1
- package/lib/typescript/network/utils/httpCompletion.d.ts.map +0 -1
- package/lib/typescript/network/utils/networkEventStore.d.ts.map +0 -1
- package/lib/typescript/network/utils/networkListener.d.ts.map +0 -1
- package/lib/typescript/network/utils/networkSavedStore.d.ts.map +0 -1
- package/lib/typescript/network/utils/networkSelectionStore.d.ts.map +0 -1
- package/lib/typescript/network/utils/selectSavedEvents.d.ts.map +0 -1
- package/lib/typescript/network/utils/withPinnedFirst.d.ts.map +0 -1
- package/lib/typescript/preset.d.ts.map +0 -1
|
@@ -1,35 +1 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
|
|
3
|
-
/**
|
|
4
|
-
* Override write receipts must admit when the rule cannot fire.
|
|
5
|
-
*
|
|
6
|
-
* Compiled by vitest.release.config.ts with `__DEV__` inlined to false — the
|
|
7
|
-
* only lane where this is observable, because `__DEV__` is a build-time
|
|
8
|
-
* constant and `vi.stubGlobal` cannot reach it.
|
|
9
|
-
*
|
|
10
|
-
* The bug this pins: `overrideForRequest` refuses in a release build, but the
|
|
11
|
-
* write paths still returned a bare `{ok: true}` and still persisted. A remote
|
|
12
|
-
* driver — Buoy MCP, the desktop dashboard, or Ask Buoy — reported "override is
|
|
13
|
-
* live" to a QA tester whose next bug report was filed against data that was
|
|
14
|
-
* never faked. Saved and inert are different states and the receipt has to say
|
|
15
|
-
* which one happened.
|
|
16
|
-
*/
|
|
17
|
-
import { describe, expect, it } from "vitest";
|
|
18
|
-
import { overridesCanApply, OVERRIDES_INACTIVE_REASON, overrideForRequest } from "../overrides/engine";
|
|
19
|
-
describe("override honesty in a release build", () => {
|
|
20
|
-
it("is compiled with __DEV__ false", () => {
|
|
21
|
-
// Guard the guard: if this lane ever ran with __DEV__ true, every
|
|
22
|
-
// assertion below would pass for the wrong reason.
|
|
23
|
-
expect(typeof __DEV__ === "undefined" || __DEV__).toBe(false);
|
|
24
|
-
});
|
|
25
|
-
it("reports that overrides cannot apply", () => {
|
|
26
|
-
expect(overridesCanApply()).toBe(false);
|
|
27
|
-
});
|
|
28
|
-
it("never applies a rule to a request", () => {
|
|
29
|
-
expect(overrideForRequest("https://api.example.com/menu", "GET")).toBeNull();
|
|
30
|
-
});
|
|
31
|
-
it("has a reason written for a person, not a log line", () => {
|
|
32
|
-
expect(OVERRIDES_INACTIVE_REASON).toMatch(/release build/i);
|
|
33
|
-
expect(OVERRIDES_INACTIVE_REASON).toMatch(/will not affect/i);
|
|
34
|
-
});
|
|
35
|
-
});
|
|
1
|
+
"use strict";import{describe as r,expect as e,it as t}from"vitest";import{overridesCanApply as a,OVERRIDES_INACTIVE_REASON as o,overrideForRequest as i}from"../overrides/engine";r("override honesty in a release build",()=>{t("is compiled with __DEV__ false",()=>{e(typeof __DEV__==="undefined"||__DEV__).toBe(false)});t("reports that overrides cannot apply",()=>{e(a()).toBe(false)});t("never applies a rule to a request",()=>{e(i("https://api.example.com/menu","GET")).toBeNull()});t("has a reason written for a person, not a log line",()=>{e(o).toMatch(/release build/i);e(o).toMatch(/will not affect/i)})});
|
|
@@ -1,76 +1 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
|
|
3
|
-
/**
|
|
4
|
-
* Extract GraphQL operation name from request data
|
|
5
|
-
*
|
|
6
|
-
* This utility extracts the operation name from GraphQL requests to enable
|
|
7
|
-
* searching and filtering by operation name rather than just URL paths.
|
|
8
|
-
*
|
|
9
|
-
* For GraphQL, all requests typically go to the same endpoint (e.g., /graphql),
|
|
10
|
-
* making URL-based search ineffective. This function extracts the actual
|
|
11
|
-
* operation name (e.g., "GetUser", "CreatePost") from the request payload.
|
|
12
|
-
*
|
|
13
|
-
* Extraction Methods (tried in order):
|
|
14
|
-
* 1. Direct operationName field in request data
|
|
15
|
-
* 2. Parse from query string using regex pattern
|
|
16
|
-
*
|
|
17
|
-
* @param requestData - The request data object (typically GraphQL query payload)
|
|
18
|
-
* @returns Operation name string or null if not found
|
|
19
|
-
*
|
|
20
|
-
* @example
|
|
21
|
-
* // Method 1: Explicit operationName field
|
|
22
|
-
* const data1 = {
|
|
23
|
-
* operationName: "GetUser",
|
|
24
|
-
* query: "query GetUser { user { id name } }"
|
|
25
|
-
* };
|
|
26
|
-
* extractOperationName(data1); // Returns "GetUser"
|
|
27
|
-
*
|
|
28
|
-
* @example
|
|
29
|
-
* // Method 2: Parse from query string
|
|
30
|
-
* const data2 = {
|
|
31
|
-
* query: "mutation CreatePost { createPost(title: \"Hello\") { id } }"
|
|
32
|
-
* };
|
|
33
|
-
* extractOperationName(data2); // Returns "CreatePost"
|
|
34
|
-
*
|
|
35
|
-
* @example
|
|
36
|
-
* // No operation name (anonymous query)
|
|
37
|
-
* const data3 = {
|
|
38
|
-
* query: "{ user { id name } }"
|
|
39
|
-
* };
|
|
40
|
-
* extractOperationName(data3); // Returns null
|
|
41
|
-
*/
|
|
42
|
-
export function extractOperationName(requestData) {
|
|
43
|
-
// Validate input is an object
|
|
44
|
-
if (!requestData || typeof requestData !== 'object') {
|
|
45
|
-
return null;
|
|
46
|
-
}
|
|
47
|
-
|
|
48
|
-
// Method 1: Check for explicit operationName field
|
|
49
|
-
// This is the standard GraphQL request format
|
|
50
|
-
if ('operationName' in requestData && requestData.operationName) {
|
|
51
|
-
const opName = requestData.operationName;
|
|
52
|
-
// Ensure it's a string and not empty
|
|
53
|
-
if (typeof opName === 'string' && opName.trim().length > 0) {
|
|
54
|
-
return opName.trim();
|
|
55
|
-
}
|
|
56
|
-
}
|
|
57
|
-
|
|
58
|
-
// Method 2: Parse from query string
|
|
59
|
-
// Handles cases where operationName field is missing or null
|
|
60
|
-
if ('query' in requestData && typeof requestData.query === 'string') {
|
|
61
|
-
const query = requestData.query;
|
|
62
|
-
|
|
63
|
-
// Match: query OperationName or mutation OperationName or subscription OperationName
|
|
64
|
-
// Pattern explanation:
|
|
65
|
-
// - (?:query|mutation|subscription) - Match operation type (non-capturing group)
|
|
66
|
-
// - \s+ - One or more whitespace characters
|
|
67
|
-
// - (\w+) - Capture operation name (letters, numbers, underscore)
|
|
68
|
-
const match = query.match(/(?:query|mutation|subscription)\s+(\w+)/);
|
|
69
|
-
if (match && match[1]) {
|
|
70
|
-
return match[1];
|
|
71
|
-
}
|
|
72
|
-
}
|
|
73
|
-
|
|
74
|
-
// No operation name found
|
|
75
|
-
return null;
|
|
76
|
-
}
|
|
1
|
+
"use strict";export function extractOperationName(n){if(!n||typeof n!=="object"){return null}if("operationName"in n&&n.operationName){const i=n.operationName;if(typeof i==="string"&&i.trim().length>0){return i.trim()}}if("query"in n&&typeof n.query==="string"){const i=n.query;const o=i.match(/(?:query|mutation|subscription)\s+(\w+)/);if(o&&o[1]){return o[1]}}return null}
|
|
@@ -1,92 +1 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
|
|
3
|
-
/**
|
|
4
|
-
* Pure network-event filtering shared by the list/copy/filter-screen hooks
|
|
5
|
-
* (rule3: reusable logic extracted to a pure function). Ported verbatim
|
|
6
|
-
* from the filtering previously inlined in `useNetworkEvents` so every
|
|
7
|
-
* subscriber applies identical semantics.
|
|
8
|
-
*/
|
|
9
|
-
|
|
10
|
-
import { urlMatchesIgnoredPattern } from "@buoy-gg/shared-ui";
|
|
11
|
-
import { searchGraphQLVariables } from "./formatGraphQLVariables";
|
|
12
|
-
|
|
13
|
-
/** Apply the user's search/method/status/host/content-type filter. */
|
|
14
|
-
export function filterNetworkEvents(events, filter) {
|
|
15
|
-
const searchLower = filter.searchText ? filter.searchText.toLowerCase() : null;
|
|
16
|
-
const methodSet = filter.method && filter.method.length > 0 ? new Set(filter.method) : null;
|
|
17
|
-
const contentTypeSet = filter.contentType && filter.contentType.length > 0 ? new Set(filter.contentType) : null;
|
|
18
|
-
let filtered = [...events];
|
|
19
|
-
if (methodSet) {
|
|
20
|
-
filtered = filtered.filter(e => methodSet.has(e.method));
|
|
21
|
-
}
|
|
22
|
-
if (filter.status && filter.status !== "all") {
|
|
23
|
-
switch (filter.status) {
|
|
24
|
-
case "success":
|
|
25
|
-
filtered = filtered.filter(e => e.status && e.status >= 200 && e.status < 300);
|
|
26
|
-
break;
|
|
27
|
-
case "error":
|
|
28
|
-
filtered = filtered.filter(e => e.error || e.status && e.status >= 400);
|
|
29
|
-
break;
|
|
30
|
-
case "pending":
|
|
31
|
-
filtered = filtered.filter(e => !e.status && !e.error);
|
|
32
|
-
break;
|
|
33
|
-
}
|
|
34
|
-
}
|
|
35
|
-
if (searchLower) {
|
|
36
|
-
filtered = filtered.filter(e => e.url.toLowerCase().includes(searchLower) || e.method.toLowerCase().includes(searchLower) || e.path?.toLowerCase().includes(searchLower) || e.host?.toLowerCase().includes(searchLower) || e.error && e.error.toLowerCase().includes(searchLower) ||
|
|
37
|
-
// Search by GraphQL operation name (e.g., "GetUser", "CreatePost")
|
|
38
|
-
e.operationName && e.operationName.toLowerCase().includes(searchLower) ||
|
|
39
|
-
// Search by GraphQL variable values (e.g., "Sandshrew", "123")
|
|
40
|
-
searchGraphQLVariables(e.graphqlVariables, searchLower));
|
|
41
|
-
}
|
|
42
|
-
if (filter.host) {
|
|
43
|
-
filtered = filtered.filter(e => e.host === filter.host);
|
|
44
|
-
}
|
|
45
|
-
if (contentTypeSet) {
|
|
46
|
-
filtered = filtered.filter(e => {
|
|
47
|
-
const headers = e.responseHeaders || e.requestHeaders;
|
|
48
|
-
const contentType = headers?.["content-type"] || headers?.["Content-Type"] || "";
|
|
49
|
-
for (const type of contentTypeSet) {
|
|
50
|
-
switch (type) {
|
|
51
|
-
case "JSON":
|
|
52
|
-
if (contentType.includes("json")) return true;
|
|
53
|
-
break;
|
|
54
|
-
case "XML":
|
|
55
|
-
if (contentType.includes("xml")) return true;
|
|
56
|
-
break;
|
|
57
|
-
case "HTML":
|
|
58
|
-
if (contentType.includes("html")) return true;
|
|
59
|
-
break;
|
|
60
|
-
case "TEXT":
|
|
61
|
-
if (contentType.includes("text")) return true;
|
|
62
|
-
break;
|
|
63
|
-
case "IMAGE":
|
|
64
|
-
if (contentType.includes("image")) return true;
|
|
65
|
-
break;
|
|
66
|
-
case "VIDEO":
|
|
67
|
-
if (contentType.includes("video")) return true;
|
|
68
|
-
break;
|
|
69
|
-
case "AUDIO":
|
|
70
|
-
if (contentType.includes("audio")) return true;
|
|
71
|
-
break;
|
|
72
|
-
case "FORM":
|
|
73
|
-
if (contentType.includes("form")) return true;
|
|
74
|
-
break;
|
|
75
|
-
case "OTHER":
|
|
76
|
-
if (!contentType || !contentType.includes("json") && !contentType.includes("xml") && !contentType.includes("html") && !contentType.includes("text") && !contentType.includes("image") && !contentType.includes("video") && !contentType.includes("audio") && !contentType.includes("form")) {
|
|
77
|
-
return true;
|
|
78
|
-
}
|
|
79
|
-
break;
|
|
80
|
-
}
|
|
81
|
-
}
|
|
82
|
-
return false;
|
|
83
|
-
});
|
|
84
|
-
}
|
|
85
|
-
return filtered;
|
|
86
|
-
}
|
|
87
|
-
|
|
88
|
-
/** Drop events matching the shared ignored-domain/URL patterns. */
|
|
89
|
-
export function applyIgnoredPatterns(events, ignoredPatterns) {
|
|
90
|
-
if (ignoredPatterns.length === 0) return events;
|
|
91
|
-
return events.filter(event => !ignoredPatterns.some(pattern => urlMatchesIgnoredPattern(event.url, pattern)));
|
|
92
|
-
}
|
|
1
|
+
"use strict";import{urlMatchesIgnoredPattern as l}from"@buoy-gg/shared-ui";import{searchGraphQLVariables as d}from"./formatGraphQLVariables";export function filterNetworkEvents(o,r){const n=r.searchText?r.searchText.toLowerCase():null;const a=r.method&&r.method.length>0?new Set(r.method):null;const u=r.contentType&&r.contentType.length>0?new Set(r.contentType):null;let s=[...o];if(a){s=s.filter(e=>a.has(e.method))}if(r.status&&r.status!=="all"){switch(r.status){case"success":s=s.filter(e=>e.status&&e.status>=200&&e.status<300);break;case"error":s=s.filter(e=>e.error||e.status&&e.status>=400);break;case"pending":s=s.filter(e=>!e.status&&!e.error);break}}if(n){s=s.filter(e=>e.url.toLowerCase().includes(n)||e.method.toLowerCase().includes(n)||e.path?.toLowerCase().includes(n)||e.host?.toLowerCase().includes(n)||e.error&&e.error.toLowerCase().includes(n)||e.operationName&&e.operationName.toLowerCase().includes(n)||d(e.graphqlVariables,n))}if(r.host){s=s.filter(e=>e.host===r.host)}if(u){s=s.filter(e=>{const c=e.responseHeaders||e.requestHeaders;const t=c?.["content-type"]||c?.["Content-Type"]||"";for(const i of u){switch(i){case"JSON":if(t.includes("json"))return true;break;case"XML":if(t.includes("xml"))return true;break;case"HTML":if(t.includes("html"))return true;break;case"TEXT":if(t.includes("text"))return true;break;case"IMAGE":if(t.includes("image"))return true;break;case"VIDEO":if(t.includes("video"))return true;break;case"AUDIO":if(t.includes("audio"))return true;break;case"FORM":if(t.includes("form"))return true;break;case"OTHER":if(!t||!t.includes("json")&&!t.includes("xml")&&!t.includes("html")&&!t.includes("text")&&!t.includes("image")&&!t.includes("video")&&!t.includes("audio")&&!t.includes("form")){return true}break}}return false})}return s}export function applyIgnoredPatterns(o,r){if(r.length===0)return o;return o.filter(n=>!r.some(a=>l(n.url,a)))}
|
|
@@ -1,213 +1 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
|
|
3
|
-
/**
|
|
4
|
-
* Format GraphQL variables for display using arrow notation
|
|
5
|
-
*
|
|
6
|
-
* Mimics React Query key display format to provide visual consistency:
|
|
7
|
-
* - React Query: ["pokemon", "Sandshrew"] → "pokemon › Sandshrew"
|
|
8
|
-
* - GraphQL: GetPokemon(id: "Sandshrew") → "GetPokemon › Sandshrew"
|
|
9
|
-
*
|
|
10
|
-
* Extracts only the values from variables (not keys) and formats them
|
|
11
|
-
* for clean, compact display in the network request list.
|
|
12
|
-
*/
|
|
13
|
-
|
|
14
|
-
/**
|
|
15
|
-
* Format a single variable value for display
|
|
16
|
-
*
|
|
17
|
-
* @param value - The variable value to format
|
|
18
|
-
* @param maxLength - Maximum length for string values (default: 30)
|
|
19
|
-
* @returns Formatted string or null if value should be skipped
|
|
20
|
-
*/
|
|
21
|
-
function formatValue(value, maxLength = 30) {
|
|
22
|
-
// Null/undefined - skip
|
|
23
|
-
if (value === null || value === undefined) {
|
|
24
|
-
return null;
|
|
25
|
-
}
|
|
26
|
-
|
|
27
|
-
// Boolean
|
|
28
|
-
if (typeof value === 'boolean') {
|
|
29
|
-
return String(value);
|
|
30
|
-
}
|
|
31
|
-
|
|
32
|
-
// Number
|
|
33
|
-
if (typeof value === 'number') {
|
|
34
|
-
return String(value);
|
|
35
|
-
}
|
|
36
|
-
|
|
37
|
-
// String
|
|
38
|
-
if (typeof value === 'string') {
|
|
39
|
-
// Truncate long strings
|
|
40
|
-
if (value.length > maxLength) {
|
|
41
|
-
return value.substring(0, maxLength - 1) + '…';
|
|
42
|
-
}
|
|
43
|
-
return value;
|
|
44
|
-
}
|
|
45
|
-
|
|
46
|
-
// Array - take first value or show count
|
|
47
|
-
if (Array.isArray(value)) {
|
|
48
|
-
if (value.length === 0) return null;
|
|
49
|
-
if (value.length === 1) {
|
|
50
|
-
return formatValue(value[0], maxLength);
|
|
51
|
-
}
|
|
52
|
-
// Multiple items - show count
|
|
53
|
-
return `${value.length} items`;
|
|
54
|
-
}
|
|
55
|
-
|
|
56
|
-
// Object - extract first string/number value
|
|
57
|
-
if (typeof value === 'object') {
|
|
58
|
-
const entries = Object.entries(value);
|
|
59
|
-
if (entries.length === 0) return null;
|
|
60
|
-
|
|
61
|
-
// Find first meaningful value
|
|
62
|
-
for (const [_, v] of entries) {
|
|
63
|
-
const formatted = formatValue(v, maxLength);
|
|
64
|
-
if (formatted) {
|
|
65
|
-
return formatted;
|
|
66
|
-
}
|
|
67
|
-
}
|
|
68
|
-
return null;
|
|
69
|
-
}
|
|
70
|
-
return null;
|
|
71
|
-
}
|
|
72
|
-
|
|
73
|
-
/**
|
|
74
|
-
* Extract variable values from GraphQL variables object
|
|
75
|
-
*
|
|
76
|
-
* Returns an array of formatted values for display with arrow notation.
|
|
77
|
-
*
|
|
78
|
-
* @param variables - GraphQL variables object
|
|
79
|
-
* @param maxValues - Maximum number of values to show (default: 3)
|
|
80
|
-
* @returns Array of formatted variable values
|
|
81
|
-
*
|
|
82
|
-
* @example
|
|
83
|
-
* formatGraphQLVariables({ id: "pikachu" })
|
|
84
|
-
* // Returns: ["pikachu"]
|
|
85
|
-
*
|
|
86
|
-
* @example
|
|
87
|
-
* formatGraphQLVariables({ userId: 123, includeProfile: true })
|
|
88
|
-
* // Returns: ["123", "true"]
|
|
89
|
-
*
|
|
90
|
-
* @example
|
|
91
|
-
* formatGraphQLVariables({ filter: { status: "active" }, limit: 10 })
|
|
92
|
-
* // Returns: ["active", "10"]
|
|
93
|
-
*/
|
|
94
|
-
export function formatGraphQLVariables(variables, maxValues = 3) {
|
|
95
|
-
if (!variables || typeof variables !== 'object') {
|
|
96
|
-
return null;
|
|
97
|
-
}
|
|
98
|
-
const values = [];
|
|
99
|
-
|
|
100
|
-
// Extract values from variables object
|
|
101
|
-
for (const [_, value] of Object.entries(variables)) {
|
|
102
|
-
const formatted = formatValue(value);
|
|
103
|
-
if (formatted) {
|
|
104
|
-
values.push(formatted);
|
|
105
|
-
}
|
|
106
|
-
|
|
107
|
-
// Stop if we've reached max values
|
|
108
|
-
if (values.length >= maxValues) {
|
|
109
|
-
break;
|
|
110
|
-
}
|
|
111
|
-
}
|
|
112
|
-
return values.length > 0 ? values : null;
|
|
113
|
-
}
|
|
114
|
-
|
|
115
|
-
/**
|
|
116
|
-
* Combine operation name with variables using arrow notation
|
|
117
|
-
*
|
|
118
|
-
* Matches React Query display pattern: "pokemon › Sandshrew"
|
|
119
|
-
* This provides visual consistency across all dev tools.
|
|
120
|
-
*
|
|
121
|
-
* @param operationName - GraphQL operation name (e.g., "GetPokemon")
|
|
122
|
-
* @param variables - GraphQL variables object
|
|
123
|
-
* @returns Formatted string with arrow notation
|
|
124
|
-
*
|
|
125
|
-
* @example
|
|
126
|
-
* formatGraphQLDisplay("GetPokemon", { id: "Sandshrew" })
|
|
127
|
-
* // Returns: "GetPokemon › Sandshrew"
|
|
128
|
-
*
|
|
129
|
-
* @example
|
|
130
|
-
* formatGraphQLDisplay("GetUser", { userId: 123, includeProfile: true })
|
|
131
|
-
* // Returns: "GetUser › 123 › true"
|
|
132
|
-
*
|
|
133
|
-
* @example
|
|
134
|
-
* formatGraphQLDisplay("GetPosts", { status: "published", limit: 10, offset: 0 })
|
|
135
|
-
* // Returns: "GetPosts › published › 10 › 0" (first 3 values by default)
|
|
136
|
-
*
|
|
137
|
-
* @example
|
|
138
|
-
* formatGraphQLDisplay("GetCurrentUser", {})
|
|
139
|
-
* // Returns: "GetCurrentUser" (no variables)
|
|
140
|
-
*/
|
|
141
|
-
export function formatGraphQLDisplay(operationName, variables) {
|
|
142
|
-
const values = formatGraphQLVariables(variables);
|
|
143
|
-
if (!values || values.length === 0) {
|
|
144
|
-
// No variables - just operation name
|
|
145
|
-
return operationName;
|
|
146
|
-
}
|
|
147
|
-
|
|
148
|
-
// Combine: "GetPokemon › Sandshrew" (matches React Query pattern)
|
|
149
|
-
return [operationName, ...values].join(" › ");
|
|
150
|
-
}
|
|
151
|
-
|
|
152
|
-
/**
|
|
153
|
-
* Search GraphQL variables for a given text
|
|
154
|
-
*
|
|
155
|
-
* Recursively searches through all variable values to find matches.
|
|
156
|
-
* Used for filtering GraphQL requests by variable content.
|
|
157
|
-
*
|
|
158
|
-
* @param variables - GraphQL variables object
|
|
159
|
-
* @param searchText - Text to search for (already lowercased)
|
|
160
|
-
* @returns true if search text found in any variable value
|
|
161
|
-
*
|
|
162
|
-
* @example
|
|
163
|
-
* searchGraphQLVariables({ id: "pikachu" }, "pika")
|
|
164
|
-
* // Returns: true
|
|
165
|
-
*
|
|
166
|
-
* @example
|
|
167
|
-
* searchGraphQLVariables({ userId: 123, name: "John" }, "123")
|
|
168
|
-
* // Returns: true
|
|
169
|
-
*/
|
|
170
|
-
export function searchGraphQLVariables(variables, searchText) {
|
|
171
|
-
if (!variables || typeof variables !== 'object') {
|
|
172
|
-
return false;
|
|
173
|
-
}
|
|
174
|
-
|
|
175
|
-
// Search through all variable values
|
|
176
|
-
for (const value of Object.values(variables)) {
|
|
177
|
-
if (searchValue(value, searchText)) {
|
|
178
|
-
return true;
|
|
179
|
-
}
|
|
180
|
-
}
|
|
181
|
-
return false;
|
|
182
|
-
}
|
|
183
|
-
|
|
184
|
-
/**
|
|
185
|
-
* Recursively search a value for matching text
|
|
186
|
-
*/
|
|
187
|
-
function searchValue(value, searchText) {
|
|
188
|
-
// String - direct match
|
|
189
|
-
if (typeof value === 'string') {
|
|
190
|
-
return value.toLowerCase().includes(searchText);
|
|
191
|
-
}
|
|
192
|
-
|
|
193
|
-
// Number - convert to string and match
|
|
194
|
-
if (typeof value === 'number') {
|
|
195
|
-
return String(value).includes(searchText);
|
|
196
|
-
}
|
|
197
|
-
|
|
198
|
-
// Boolean - convert to string and match
|
|
199
|
-
if (typeof value === 'boolean') {
|
|
200
|
-
return String(value).includes(searchText);
|
|
201
|
-
}
|
|
202
|
-
|
|
203
|
-
// Array - search each item
|
|
204
|
-
if (Array.isArray(value)) {
|
|
205
|
-
return value.some(item => searchValue(item, searchText));
|
|
206
|
-
}
|
|
207
|
-
|
|
208
|
-
// Object - search nested values
|
|
209
|
-
if (typeof value === 'object' && value !== null) {
|
|
210
|
-
return Object.values(value).some(v => searchValue(v, searchText));
|
|
211
|
-
}
|
|
212
|
-
return false;
|
|
213
|
-
}
|
|
1
|
+
"use strict";function o(r,n=30){if(r===null||r===void 0){return null}if(typeof r==="boolean"){return String(r)}if(typeof r==="number"){return String(r)}if(typeof r==="string"){if(r.length>n){return r.substring(0,n-1)+"\u2026"}return r}if(Array.isArray(r)){if(r.length===0)return null;if(r.length===1){return o(r[0],n)}return`${r.length} items`}if(typeof r==="object"){const t=Object.entries(r);if(t.length===0)return null;for(const[s,e]of t){const f=o(e,n);if(f){return f}}return null}return null}export function formatGraphQLVariables(r,n=3){if(!r||typeof r!=="object"){return null}const t=[];for(const[s,e]of Object.entries(r)){const f=o(e);if(f){t.push(f)}if(t.length>=n){break}}return t.length>0?t:null}export function formatGraphQLDisplay(r,n){const t=formatGraphQLVariables(n);if(!t||t.length===0){return r}return[r,...t].join(" \u203A ")}export function searchGraphQLVariables(r,n){if(!r||typeof r!=="object"){return false}for(const t of Object.values(r)){if(i(t,n)){return true}}return false}function i(r,n){if(typeof r==="string"){return r.toLowerCase().includes(n)}if(typeof r==="number"){return String(r).includes(n)}if(typeof r==="boolean"){return String(r).includes(n)}if(Array.isArray(r)){return r.some(t=>i(t,n))}if(typeof r==="object"&&r!==null){return Object.values(r).some(t=>i(t,n))}return false}
|
|
@@ -1,9 +1 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
|
|
3
|
-
/**
|
|
4
|
-
* Formatting utilities for network events
|
|
5
|
-
* Re-exports shared utilities to maintain backward compatibility
|
|
6
|
-
*/
|
|
7
|
-
|
|
8
|
-
// Re-export shared formatting utilities
|
|
9
|
-
export { formatBytes, formatDuration, formatHttpStatus, getMethodColor } from "@buoy-gg/shared-ui";
|
|
1
|
+
"use strict";export{formatBytes,formatDuration,formatHttpStatus,getMethodColor}from"@buoy-gg/shared-ui";
|
|
@@ -1,67 +1,2 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
|
|
3
|
-
/**
|
|
4
|
-
* Render a captured request as a runnable `curl` command.
|
|
5
|
-
*
|
|
6
|
-
* The point is to get a request OUT of the app and into a terminal, Postman or
|
|
7
|
-
* a bug report without retyping it — so the output has to actually run, which
|
|
8
|
-
* makes quoting the whole job.
|
|
9
|
-
*/
|
|
10
|
-
|
|
11
|
-
/** Headers that describe the captured hop rather than the request, and would
|
|
12
|
-
* either break the replay or lie about it. curl sets these itself. */
|
|
13
|
-
const SKIPPED_HEADERS = new Set(["content-length",
|
|
14
|
-
// curl recomputes it; a stale value truncates the body
|
|
15
|
-
"host",
|
|
16
|
-
// implied by the URL
|
|
17
|
-
"connection", "accept-encoding" // curl would then have to decode what it asked for
|
|
18
|
-
]);
|
|
19
|
-
|
|
20
|
-
/**
|
|
21
|
-
* Single-quote for POSIX shells.
|
|
22
|
-
*
|
|
23
|
-
* Inside single quotes every byte is literal, so the ONLY character needing
|
|
24
|
-
* care is the single quote itself — closed, escaped, reopened. Newlines and
|
|
25
|
-
* `$`/backtick survive untouched, which is what makes this safe for JSON
|
|
26
|
-
* bodies and tokens.
|
|
27
|
-
*/
|
|
28
|
-
function shellQuote(value) {
|
|
29
|
-
return `'${value.replace(/'/g, `'\\''`)}'`;
|
|
30
|
-
}
|
|
31
|
-
function serializeBody(data) {
|
|
32
|
-
if (data === undefined || data === null) return null;
|
|
33
|
-
if (typeof data === "string") return data;
|
|
34
|
-
try {
|
|
35
|
-
return JSON.stringify(data);
|
|
36
|
-
} catch {
|
|
37
|
-
// Circular or otherwise unserializable — better to emit no body than a
|
|
38
|
-
// command that silently posts "[object Object]".
|
|
39
|
-
return null;
|
|
40
|
-
}
|
|
41
|
-
}
|
|
42
|
-
export function generateCurl(event) {
|
|
43
|
-
const method = (event.method || "GET").toUpperCase();
|
|
44
|
-
const body = serializeBody(event.requestData);
|
|
45
|
-
|
|
46
|
-
// Flags are collected as whole `-X PATCH` strings rather than as a flat token
|
|
47
|
-
// list, so the line-wrap below can't mis-pair them — an earlier version
|
|
48
|
-
// destructured `[cmd, url, ...rest]` and put the URL in the wrong slot the
|
|
49
|
-
// moment an -X was present.
|
|
50
|
-
const flags = [];
|
|
51
|
-
|
|
52
|
-
// curl defaults to GET, and to POST once -d is present, so -X only carries
|
|
53
|
-
// information when it disagrees with that.
|
|
54
|
-
if (method !== "GET" && !(method === "POST" && body !== null)) {
|
|
55
|
-
flags.push(`-X ${method}`);
|
|
56
|
-
}
|
|
57
|
-
for (const [key, value] of Object.entries(event.requestHeaders || {})) {
|
|
58
|
-
if (SKIPPED_HEADERS.has(key.toLowerCase())) continue;
|
|
59
|
-
flags.push(`-H ${shellQuote(`${key}: ${value}`)}`);
|
|
60
|
-
}
|
|
61
|
-
if (body !== null) flags.push(`--data-raw ${shellQuote(body)}`);
|
|
62
|
-
const head = `curl ${shellQuote(event.url)}`;
|
|
63
|
-
if (flags.length === 0) return head;
|
|
64
|
-
// One flag per line — these get long, and a wrapped blob is unreadable in a
|
|
65
|
-
// terminal or pasted into a ticket.
|
|
66
|
-
return `${head} \\\n ${flags.join(" \\\n ")}`;
|
|
67
|
-
}
|
|
1
|
+
"use strict";const i=new Set(["content-length","host","connection","accept-encoding"]);function o(e){return`'${e.replace(/'/g,`'\\''`)}'`}function l(e){if(e===void 0||e===null)return null;if(typeof e==="string")return e;try{return JSON.stringify(e)}catch{return null}}export function generateCurl(e){const t=(e.method||"GET").toUpperCase();const r=l(e.requestData);const n=[];if(t!=="GET"&&!(t==="POST"&&r!==null)){n.push(`-X ${t}`)}for(const[s,c]of Object.entries(e.requestHeaders||{})){if(i.has(s.toLowerCase()))continue;n.push(`-H ${o(`${s}: ${c}`)}`)}if(r!==null)n.push(`--data-raw ${o(r)}`);const u=`curl ${o(e.url)}`;if(n.length===0)return u;return`${u} \\
|
|
2
|
+
${n.join(" \\\n ")}`}
|