@scalar/api-client 2.19.2 → 2.20.0
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/CHANGELOG.md +55 -0
- package/dist/components/CodeInput/CodeInput.vue.d.ts.map +1 -1
- package/dist/components/CommandPalette/TheCommandPalette.vue.d.ts.map +1 -1
- package/dist/components/CommandPalette/WatchModeToggle.vue.d.ts.map +1 -1
- package/dist/components/DataTable/DataTable.vue.d.ts.map +1 -1
- package/dist/components/DataTable/DataTableInput.vue.d.ts.map +1 -1
- package/dist/components/Form/Form.vue.d.ts.map +1 -1
- package/dist/components/HttpMethod/HttpMethod.vue.d.ts.map +1 -1
- package/dist/components/ImportCollection/ImportCollectionModal.vue.d.ts.map +1 -1
- package/dist/components/ScalarAsciiArt.vue.d.ts.map +1 -1
- package/dist/components/SectionFilterButton.vue.d.ts.map +1 -1
- package/dist/components/Server/ServerDropdownItem.vue.d.ts.map +1 -1
- package/dist/components/Server/ServerVariablesSelect.vue.d.ts.map +1 -1
- package/dist/components/SideNav/DownloadAppButton.vue.d.ts.map +1 -1
- package/dist/components/SideNav/SideNav.vue.d.ts.map +1 -1
- package/dist/components/SideNav/SideNavLink.vue.d.ts.map +1 -1
- package/dist/components/Sidebar/Sidebar.vue.d.ts.map +1 -1
- package/dist/components/TopNav/TopNavItem.vue.d.ts.map +1 -1
- package/dist/components/ViewLayout/ViewLayoutCollapse.vue.d.ts.map +1 -1
- package/dist/hooks/useFileDialog.d.ts +4 -4
- package/dist/layouts/App/MainLayout.vue.d.ts.map +1 -1
- package/dist/style.css +1 -1
- package/dist/v2/blocks/operation-block/OperationBlock.vue.d.ts +0 -9
- package/dist/v2/blocks/operation-block/OperationBlock.vue.d.ts.map +1 -1
- package/dist/v2/blocks/operation-block/OperationBlock.vue.js +126 -67
- package/dist/v2/blocks/operation-block/components/Header.vue.d.ts +6 -0
- package/dist/v2/blocks/operation-block/components/Header.vue.d.ts.map +1 -1
- package/dist/v2/blocks/operation-block/components/Header.vue.js +2 -2
- package/dist/v2/blocks/operation-block/components/Header.vue2.js +25 -24
- package/dist/v2/blocks/operation-block/helpers/build-request-cookie-header.d.ts +1 -1
- package/dist/v2/blocks/operation-block/helpers/build-request-cookie-header.d.ts.map +1 -1
- package/dist/v2/blocks/operation-block/helpers/build-request-cookie-header.js +1 -1
- package/dist/v2/blocks/operation-block/helpers/build-request-parameters.d.ts +0 -1
- package/dist/v2/blocks/operation-block/helpers/build-request-parameters.d.ts.map +1 -1
- package/dist/v2/blocks/operation-block/helpers/build-request-parameters.js +96 -48
- package/dist/v2/blocks/operation-block/helpers/build-request.d.ts.map +1 -1
- package/dist/v2/blocks/operation-block/helpers/build-request.js +41 -39
- package/dist/v2/blocks/operation-block/helpers/har-to-fetch-request.d.ts +42 -0
- package/dist/v2/blocks/operation-block/helpers/har-to-fetch-request.d.ts.map +1 -0
- package/dist/v2/blocks/operation-block/helpers/har-to-fetch-request.js +31 -0
- package/dist/v2/blocks/operation-block/helpers/har-to-fetch-response.d.ts +66 -0
- package/dist/v2/blocks/operation-block/helpers/har-to-fetch-response.d.ts.map +1 -0
- package/dist/v2/blocks/operation-block/helpers/har-to-fetch-response.js +43 -0
- package/dist/v2/blocks/operation-block/helpers/send-request.d.ts +1 -0
- package/dist/v2/blocks/operation-block/helpers/send-request.d.ts.map +1 -1
- package/dist/v2/blocks/operation-block/helpers/send-request.js +40 -38
- package/dist/v2/blocks/operation-block/helpers/serialize-parameter.d.ts +96 -0
- package/dist/v2/blocks/operation-block/helpers/serialize-parameter.d.ts.map +1 -0
- package/dist/v2/blocks/operation-block/helpers/serialize-parameter.js +49 -0
- package/dist/v2/blocks/operation-code-sample/helpers/operation-to-har/operation-to-har.d.ts.map +1 -1
- package/dist/v2/blocks/operation-code-sample/helpers/operation-to-har/operation-to-har.js +16 -17
- package/dist/v2/blocks/operation-code-sample/helpers/operation-to-har/process-parameters.d.ts +1 -2
- package/dist/v2/blocks/operation-code-sample/helpers/operation-to-har/process-parameters.d.ts.map +1 -1
- package/dist/v2/blocks/operation-code-sample/helpers/operation-to-har/process-parameters.js +109 -152
- package/dist/v2/blocks/request-block/components/RequestTableRow.vue.d.ts.map +1 -1
- package/dist/v2/blocks/request-block/helpers/get-default-headers.js +1 -1
- package/dist/v2/blocks/response-block/ResponseBlock.vue.d.ts.map +1 -1
- package/dist/v2/blocks/response-block/components/ResponseBodyPreview.vue.d.ts.map +1 -1
- package/dist/v2/blocks/response-block/components/ResponseBodyToggle.vue.d.ts.map +1 -1
- package/dist/v2/blocks/response-block/components/ResponseEmpty.vue.d.ts.map +1 -1
- package/dist/v2/blocks/scalar-address-bar-block/components/AddressBar.vue.d.ts +6 -0
- package/dist/v2/blocks/scalar-address-bar-block/components/AddressBar.vue.d.ts.map +1 -1
- package/dist/v2/blocks/scalar-address-bar-block/components/AddressBar.vue.js +2 -2
- package/dist/v2/blocks/scalar-address-bar-block/components/AddressBar.vue2.js +24 -23
- package/dist/v2/blocks/scalar-address-bar-block/components/AddressBarHistory.vue.d.ts +2 -3
- package/dist/v2/blocks/scalar-address-bar-block/components/AddressBarHistory.vue.d.ts.map +1 -1
- package/dist/v2/blocks/scalar-address-bar-block/components/AddressBarHistory.vue.js +2 -2
- package/dist/v2/blocks/scalar-address-bar-block/components/AddressBarHistory.vue2.js +20 -20
- package/dist/v2/blocks/scalar-auth-selector-block/components/AuthSelector.vue.d.ts.map +1 -1
- package/dist/v2/blocks/scalar-auth-selector-block/components/OAuthScopesInput.vue.d.ts.map +1 -1
- package/dist/v2/blocks/scalar-auth-selector-block/components/RequestAuthDataTable.vue.d.ts.map +1 -1
- package/dist/v2/blocks/scalar-auth-selector-block/components/RequestAuthTab.vue.d.ts.map +1 -1
- package/dist/v2/components/code-input/CodeInput.vue.d.ts.map +1 -1
- package/dist/v2/components/data-table/DataTable.vue.d.ts.map +1 -1
- package/dist/v2/components/data-table/DataTableInput.vue.d.ts.map +1 -1
- package/dist/v2/components/server/ServerDropdownItem.vue.d.ts.map +1 -1
- package/dist/v2/components/sidebar/Sidebar.vue.d.ts +5 -0
- package/dist/v2/components/sidebar/Sidebar.vue.d.ts.map +1 -1
- package/dist/v2/components/sidebar/Sidebar.vue.js +60 -54
- package/dist/v2/features/app/app-events.d.ts.map +1 -1
- package/dist/v2/features/app/app-events.js +53 -42
- package/dist/v2/features/app/app-state.d.ts.map +1 -1
- package/dist/v2/features/app/app-state.js +72 -72
- package/dist/v2/features/app/components/AppSidebar.vue.d.ts.map +1 -1
- package/dist/v2/features/app/components/AppSidebar.vue.js +1 -1
- package/dist/v2/features/app/components/AppSidebar.vue2.js +84 -76
- package/dist/v2/features/app/components/DesktopTab.vue.d.ts.map +1 -1
- package/dist/v2/features/app/helpers/routes.d.ts +2 -2
- package/dist/v2/features/collection/DocumentCollection.vue.d.ts.map +1 -1
- package/dist/v2/features/collection/DocumentCollection.vue.js +82 -43
- package/dist/v2/features/collection/components/Settings.vue.d.ts.map +1 -1
- package/dist/v2/features/collection/components/Settings.vue.js +9 -10
- package/dist/v2/features/command-palette/components/CommandPaletteImport.vue.d.ts +1 -3
- package/dist/v2/features/command-palette/components/CommandPaletteImport.vue.d.ts.map +1 -1
- package/dist/v2/features/command-palette/components/TheCommandPalette.vue.d.ts.map +1 -1
- package/dist/v2/features/command-palette/components/WatchModeToggle.vue.d.ts.map +1 -1
- package/dist/v2/features/environments/components/EnvironmentVariablesDropdown.vue.d.ts.map +1 -1
- package/dist/v2/features/modal/Modal.vue.d.ts +1 -1
- package/dist/v2/features/modal/Modal.vue.d.ts.map +1 -1
- package/dist/v2/features/modal/Modal.vue.js +2 -2
- package/dist/v2/features/modal/Modal.vue2.js +31 -31
- package/dist/v2/features/modal/helpers/map-hidden-clients-config.d.ts +8 -0
- package/dist/v2/features/modal/helpers/map-hidden-clients-config.d.ts.map +1 -0
- package/dist/v2/features/modal/helpers/map-hidden-clients-config.js +36 -0
- package/dist/v2/features/modal/index.d.ts +1 -0
- package/dist/v2/features/modal/index.d.ts.map +1 -1
- package/dist/v2/features/modal/index.js +4 -2
- package/dist/v2/features/operation/Operation.vue.d.ts +5 -2
- package/dist/v2/features/operation/Operation.vue.d.ts.map +1 -1
- package/dist/v2/features/operation/Operation.vue.js +48 -35
- package/dist/v2/features/operation/helpers/get-selected-server.d.ts +2 -1
- package/dist/v2/features/operation/helpers/get-selected-server.d.ts.map +1 -1
- package/dist/v2/features/operation/helpers/get-selected-server.js +2 -2
- package/dist/v2/features/search/components/SearchResult.vue.d.ts.map +1 -1
- package/dist/v2/features/settings/CollectionSettings.vue.d.ts +0 -2
- package/dist/v2/features/settings/CollectionSettings.vue.d.ts.map +1 -1
- package/dist/v2/features/settings/CollectionSettings.vue.js +110 -135
- package/dist/v2/features/settings/components/Appearance.vue.d.ts.map +1 -1
- package/dist/v2/helpers/get-servers.d.ts +23 -0
- package/dist/v2/helpers/get-servers.d.ts.map +1 -0
- package/dist/v2/helpers/get-servers.js +66 -0
- package/dist/v2/helpers/index.d.ts +1 -0
- package/dist/v2/helpers/index.d.ts.map +1 -1
- package/dist/v2/helpers/index.js +4 -2
- package/dist/v2/workspace-events.d.ts.map +1 -1
- package/dist/v2/workspace-events.js +12 -6
- package/dist/views/Collection/components/EnvironmentForm.vue.d.ts.map +1 -1
- package/dist/views/Environment/Environment.vue.d.ts.map +1 -1
- package/dist/views/Environment/EnvironmentVariableDropdown.vue.d.ts.map +1 -1
- package/dist/views/Request/Request.vue.d.ts.map +1 -1
- package/dist/views/Request/RequestRoot.vue.d.ts.map +1 -1
- package/dist/views/Request/RequestSection/RequestAuth/OAuthScopesInput.vue.d.ts.map +1 -1
- package/dist/views/Request/RequestSection/RequestAuth/RequestAuth.vue.d.ts.map +1 -1
- package/dist/views/Request/RequestSection/RequestAuth/RequestAuthTab.vue.d.ts.map +1 -1
- package/dist/views/Request/RequestSection/RequestParams.vue.d.ts.map +1 -1
- package/dist/views/Request/RequestSection/RequestTable.vue.d.ts.map +1 -1
- package/dist/views/Request/RequestSidebar.vue.d.ts.map +1 -1
- package/dist/views/Request/RequestSidebarItem.vue.d.ts.map +1 -1
- package/dist/views/Request/RequestSubpageHeader.vue.d.ts.map +1 -1
- package/dist/views/Request/ResponseSection/ResponseBodyPreview.vue.d.ts.map +1 -1
- package/dist/views/Request/ResponseSection/ResponseBodyToggle.vue.d.ts.map +1 -1
- package/dist/views/Request/ResponseSection/ResponseEmpty.vue.d.ts.map +1 -1
- package/dist/views/Request/ResponseSection/ResponseEmpty.vue2.js +1 -1
- package/dist/views/Request/ResponseSection/ResponseSection.vue.d.ts.map +1 -1
- package/dist/views/Settings/SettingsGeneral.vue.d.ts.map +1 -1
- package/dist/views/Settings/components/SettingsAppearance.vue.d.ts.map +1 -1
- package/package.json +12 -12
- package/dist/v2/blocks/operation-block/helpers/get-delimiter.js +0 -15
|
@@ -1,56 +1,104 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import {
|
|
3
|
-
import {
|
|
4
|
-
import {
|
|
5
|
-
import {
|
|
6
|
-
import {
|
|
7
|
-
import { getExample as
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
1
|
+
import { isDefined as k } from "@scalar/helpers/array/is-defined";
|
|
2
|
+
import { replaceEnvVariables as y } from "@scalar/helpers/regex/replace-variables";
|
|
3
|
+
import { getResolvedRef as g } from "@scalar/workspace-store/helpers/get-resolved-ref";
|
|
4
|
+
import { xScalarCookieSchema as u } from "@scalar/workspace-store/schemas/extensions/general/x-scalar-cookies";
|
|
5
|
+
import { coerceValue as S } from "@scalar/workspace-store/schemas/typebox-coerce";
|
|
6
|
+
import { isParamDisabled as m } from "../../request-block/helpers/is-param-disabled.js";
|
|
7
|
+
import { getExample as z } from "./get-example.js";
|
|
8
|
+
import { serializeSimpleStyle as h, serializeFormStyleForCookies as b, serializeContentValue as x, serializeDeepObjectStyle as v, serializeSpaceDelimitedStyle as C, serializePipeDelimitedStyle as D, serializeFormStyle as $ } from "./serialize-parameter.js";
|
|
9
|
+
const a = (o, s) => "explode" in o && o.explode !== void 0 ? o.explode : s, L = (o = [], s = {}, l = "default") => {
|
|
10
|
+
const e = {
|
|
11
|
+
cookies: [],
|
|
12
|
+
headers: {},
|
|
13
|
+
pathVariables: {},
|
|
14
|
+
urlParams: new URLSearchParams()
|
|
15
|
+
};
|
|
16
|
+
if (o.length === 0)
|
|
17
|
+
return e;
|
|
18
|
+
for (const c of o) {
|
|
19
|
+
const r = g(c), n = z(r, l, void 0);
|
|
20
|
+
if (!n || m(r, n))
|
|
21
|
+
continue;
|
|
22
|
+
const i = typeof n.value == "string" ? y(n.value, s) : n.value, t = y(r.name, s);
|
|
23
|
+
switch (r.in) {
|
|
24
|
+
case "header": {
|
|
25
|
+
if (t.toLowerCase() === "content-type" && i === "multipart/form-data")
|
|
26
|
+
break;
|
|
27
|
+
const f = h(i, a(r, !1));
|
|
28
|
+
if (!k(f))
|
|
29
|
+
break;
|
|
30
|
+
const p = String(f);
|
|
31
|
+
e.headers[t] ? e.headers[t] = `${e.headers[t]},${p}` : e.headers[t] = p;
|
|
32
|
+
break;
|
|
33
|
+
}
|
|
34
|
+
case "path": {
|
|
35
|
+
const d = h(i, a(r, !1));
|
|
36
|
+
e.pathVariables[t] = encodeURIComponent(String(d));
|
|
37
|
+
break;
|
|
38
|
+
}
|
|
39
|
+
case "query": {
|
|
40
|
+
w(r, t, i, e.urlParams);
|
|
41
|
+
break;
|
|
25
42
|
}
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
t.urlParams.append(o, r);
|
|
30
|
-
else {
|
|
31
|
-
const m = t.urlParams.get(o);
|
|
32
|
-
if (m) {
|
|
33
|
-
const x = v(h);
|
|
34
|
-
t.urlParams.set(o, `${m}${x}${r}`);
|
|
35
|
-
} else
|
|
36
|
-
t.urlParams.set(o, r);
|
|
37
|
-
}
|
|
43
|
+
case "cookie": {
|
|
44
|
+
P(t, i, a(r, !0), e.cookies);
|
|
45
|
+
break;
|
|
38
46
|
}
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
47
|
+
}
|
|
48
|
+
}
|
|
49
|
+
return e;
|
|
50
|
+
}, w = (o, s, l, e) => {
|
|
51
|
+
const c = "explode" in o && o.explode !== void 0 ? o.explode : !0, r = "style" in o && o.style ? o.style : "form";
|
|
52
|
+
if ("content" in o && o.content) {
|
|
53
|
+
const i = Object.keys(o.content)[0] ?? "application/json", t = x(l, i);
|
|
54
|
+
e.set(s, t);
|
|
55
|
+
return;
|
|
56
|
+
}
|
|
57
|
+
if (r === "deepObject" && c) {
|
|
58
|
+
const i = v(s, l);
|
|
59
|
+
for (const t of i)
|
|
60
|
+
e.append(t.key, t.value);
|
|
61
|
+
return;
|
|
62
|
+
}
|
|
63
|
+
if (r === "spaceDelimited") {
|
|
64
|
+
const i = C(l), t = e.get(s);
|
|
65
|
+
e.set(s, t ? `${t} ${i}` : i);
|
|
66
|
+
return;
|
|
67
|
+
}
|
|
68
|
+
if (r === "pipeDelimited") {
|
|
69
|
+
const i = D(l), t = e.get(s);
|
|
70
|
+
e.set(s, t ? `${t}|${i}` : i);
|
|
71
|
+
return;
|
|
72
|
+
}
|
|
73
|
+
const n = $(l, c);
|
|
74
|
+
if (Array.isArray(n))
|
|
75
|
+
for (const i of n) {
|
|
76
|
+
const t = i.key || s;
|
|
77
|
+
e.append(t, String(i.value));
|
|
78
|
+
}
|
|
79
|
+
else
|
|
80
|
+
e.append(s, String(n));
|
|
81
|
+
}, P = (o, s, l, e) => {
|
|
82
|
+
const c = b(s, l);
|
|
83
|
+
if (Array.isArray(c))
|
|
84
|
+
for (const r of c) {
|
|
85
|
+
const n = r.key || o;
|
|
86
|
+
e.push(
|
|
87
|
+
S(u, {
|
|
88
|
+
name: n,
|
|
89
|
+
value: String(r.value),
|
|
43
90
|
path: "/"
|
|
44
91
|
})
|
|
45
|
-
)
|
|
46
|
-
},
|
|
47
|
-
{
|
|
48
|
-
cookies: [],
|
|
49
|
-
headers: {},
|
|
50
|
-
pathVariables: {},
|
|
51
|
-
urlParams: new URLSearchParams()
|
|
92
|
+
);
|
|
52
93
|
}
|
|
53
|
-
|
|
94
|
+
else
|
|
95
|
+
e.push(
|
|
96
|
+
S(u, {
|
|
97
|
+
name: o,
|
|
98
|
+
value: String(c),
|
|
99
|
+
path: "/"
|
|
100
|
+
})
|
|
101
|
+
);
|
|
54
102
|
};
|
|
55
103
|
export {
|
|
56
104
|
L as buildRequestParameters
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"build-request.d.ts","sourceRoot":"","sources":["../../../../../src/v2/blocks/operation-block/helpers/build-request.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,mCAAmC,CAAA;AAGnE,OAAO,KAAK,EAAE,kBAAkB,EAAE,MAAM,2EAA2E,CAAA;AACnH,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,qEAAqE,CAAA;AACxG,OAAO,KAAK,EAAE,oBAAoB,EAAE,YAAY,EAAE,MAAM,8DAA8D,CAAA;AACtH,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,uDAAuD,CAAA;AAG5F,OAAO,EAAU,KAAK,aAAa,EAAkB,MAAM,eAAe,CAAA;AAU1E;;;;;;;;;;;GAWG;AACH,eAAO,MAAM,YAAY,GAAI,iHAU1B;IACD,8CAA8C;IAC9C,WAAW,EAAE,kBAAkB,CAAA;IAC/B,qCAAqC;IACrC,UAAU,EAAE,MAAM,CAAA;IAClB,mCAAmC;IACnC,aAAa,EAAE,aAAa,EAAE,CAAA;IAC9B,uCAAuC;IACvC,MAAM,EAAE,UAAU,CAAA;IAClB,2BAA2B;IAC3B,SAAS,EAAE,eAAe,CAAA;IAC1B,gCAAgC;IAChC,IAAI,EAAE,MAAM,CAAA;IACZ,oDAAoD;IACpD,QAAQ,EAAE,MAAM,CAAA;IAChB,wBAAwB;IACxB,MAAM,EAAE,YAAY,GAAG,IAAI,CAAA;IAC3B,8DAA8D;IAC9D,uBAAuB,EAAE,oBAAoB,EAAE,CAAA;CAChD,KAAG,aAAa,CAAC;IAChB,UAAU,EAAE,eAAe,CAAA;IAC3B,OAAO,EAAE,OAAO,CAAA;IAChB,YAAY,EAAE,OAAO,CAAA;CACtB,
|
|
1
|
+
{"version":3,"file":"build-request.d.ts","sourceRoot":"","sources":["../../../../../src/v2/blocks/operation-block/helpers/build-request.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,mCAAmC,CAAA;AAGnE,OAAO,KAAK,EAAE,kBAAkB,EAAE,MAAM,2EAA2E,CAAA;AACnH,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,qEAAqE,CAAA;AACxG,OAAO,KAAK,EAAE,oBAAoB,EAAE,YAAY,EAAE,MAAM,8DAA8D,CAAA;AACtH,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,uDAAuD,CAAA;AAG5F,OAAO,EAAU,KAAK,aAAa,EAAkB,MAAM,eAAe,CAAA;AAU1E;;;;;;;;;;;GAWG;AACH,eAAO,MAAM,YAAY,GAAI,iHAU1B;IACD,8CAA8C;IAC9C,WAAW,EAAE,kBAAkB,CAAA;IAC/B,qCAAqC;IACrC,UAAU,EAAE,MAAM,CAAA;IAClB,mCAAmC;IACnC,aAAa,EAAE,aAAa,EAAE,CAAA;IAC9B,uCAAuC;IACvC,MAAM,EAAE,UAAU,CAAA;IAClB,2BAA2B;IAC3B,SAAS,EAAE,eAAe,CAAA;IAC1B,gCAAgC;IAChC,IAAI,EAAE,MAAM,CAAA;IACZ,oDAAoD;IACpD,QAAQ,EAAE,MAAM,CAAA;IAChB,wBAAwB;IACxB,MAAM,EAAE,YAAY,GAAG,IAAI,CAAA;IAC3B,8DAA8D;IAC9D,uBAAuB,EAAE,oBAAoB,EAAE,CAAA;CAChD,KAAG,aAAa,CAAC;IAChB,UAAU,EAAE,eAAe,CAAA;IAC3B,OAAO,EAAE,OAAO,CAAA;IAChB,YAAY,EAAE,OAAO,CAAA;CACtB,CA0FA,CAAA"}
|
|
@@ -1,65 +1,67 @@
|
|
|
1
|
-
import { shouldUseProxy as v, redirectToProxy as
|
|
2
|
-
import { getResolvedRef as
|
|
3
|
-
import { isElectron as
|
|
4
|
-
import { ERRORS as
|
|
5
|
-
import { getEnvironmentVariables as
|
|
6
|
-
import { getResolvedUrl as
|
|
7
|
-
import { getDefaultHeaders as
|
|
1
|
+
import { shouldUseProxy as v, redirectToProxy as w } from "@scalar/oas-utils/helpers";
|
|
2
|
+
import { getResolvedRef as A } from "@scalar/workspace-store/helpers/get-resolved-ref";
|
|
3
|
+
import { isElectron as U } from "../../../../libs/electron.js";
|
|
4
|
+
import { ERRORS as h, normalizeError as D } from "../../../../libs/errors.js";
|
|
5
|
+
import { getEnvironmentVariables as L } from "./get-environment-variables.js";
|
|
6
|
+
import { getResolvedUrl as B } from "./get-resolved-url.js";
|
|
7
|
+
import { getDefaultHeaders as T } from "../../request-block/helpers/get-default-headers.js";
|
|
8
8
|
import { buildRequestBody as V } from "./build-request-body.js";
|
|
9
9
|
import { buildRequestCookieHeader as I } from "./build-request-cookie-header.js";
|
|
10
|
-
import { buildRequestParameters as
|
|
11
|
-
import { buildRequestSecurity as
|
|
10
|
+
import { buildRequestParameters as _ } from "./build-request-parameters.js";
|
|
11
|
+
import { buildRequestSecurity as x } from "./build-request-security.js";
|
|
12
12
|
const W = ({
|
|
13
|
-
environment:
|
|
14
|
-
exampleKey:
|
|
13
|
+
environment: m,
|
|
14
|
+
exampleKey: r = "default",
|
|
15
15
|
globalCookies: k,
|
|
16
|
-
method:
|
|
17
|
-
operation:
|
|
18
|
-
path:
|
|
19
|
-
proxyUrl:
|
|
20
|
-
server:
|
|
16
|
+
method: c,
|
|
17
|
+
operation: o,
|
|
18
|
+
path: C,
|
|
19
|
+
proxyUrl: f,
|
|
20
|
+
server: P,
|
|
21
21
|
selectedSecuritySchemes: q
|
|
22
22
|
}) => {
|
|
23
23
|
try {
|
|
24
|
-
const
|
|
25
|
-
(
|
|
24
|
+
const n = A(o.requestBody), t = L(m), s = _(o.parameters ?? [], t, r), d = x(q, t), H = T({ method: c, operation: o, exampleKey: r, hideDisabledHeaders: !0 }).filter((l) => !l.isOverridden).reduce(
|
|
25
|
+
(l, g) => (l[g.name] = g.defaultValue, l),
|
|
26
26
|
{}
|
|
27
|
-
), ...
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
27
|
+
), e = new Headers({ ...H, ...s.headers, ...d.headers }), E = new URLSearchParams([...s.urlParams, ...d.urlParams]), a = V(n, t, r);
|
|
28
|
+
a && (a instanceof FormData || a instanceof URLSearchParams) && e.delete("Content-Type");
|
|
29
|
+
const i = B({ environment: m, server: P, path: C, pathVariables: s.pathVariables, urlParams: E });
|
|
30
|
+
if (!i)
|
|
31
|
+
throw h.URL_EMPTY;
|
|
32
|
+
const R = v(f, i), y = w(f, i), b = e.get("User-Agent");
|
|
33
|
+
U() && b && e.set("X-Scalar-User-Agent", b);
|
|
32
34
|
const u = I({
|
|
33
|
-
paramCookies: [...
|
|
35
|
+
paramCookies: [...s.cookies, ...d.cookies],
|
|
34
36
|
globalCookies: k,
|
|
35
|
-
env:
|
|
36
|
-
originalCookieHeader: e.Cookie
|
|
37
|
-
url:
|
|
38
|
-
useCustomCookieHeader:
|
|
39
|
-
disabledGlobalCookies:
|
|
37
|
+
env: t,
|
|
38
|
+
originalCookieHeader: e.get("Cookie"),
|
|
39
|
+
url: i,
|
|
40
|
+
useCustomCookieHeader: U() || R,
|
|
41
|
+
disabledGlobalCookies: o["x-scalar-disable-parameters"]?.["global-cookies"]?.[r] ?? {}
|
|
40
42
|
});
|
|
41
|
-
u && (
|
|
42
|
-
const
|
|
43
|
+
u && e.set(u.name, u.value);
|
|
44
|
+
const p = new AbortController(), S = new Request(y, {
|
|
43
45
|
/**
|
|
44
46
|
* Ensure that all methods are uppercased (though only needed for patch)
|
|
45
47
|
*
|
|
46
48
|
* @see https://github.com/whatwg/fetch/issues/50
|
|
47
49
|
*/
|
|
48
|
-
method:
|
|
50
|
+
method: c.toUpperCase(),
|
|
49
51
|
headers: e,
|
|
50
|
-
signal:
|
|
51
|
-
body:
|
|
52
|
+
signal: p.signal,
|
|
53
|
+
body: a
|
|
52
54
|
});
|
|
53
55
|
return [
|
|
54
56
|
null,
|
|
55
57
|
{
|
|
56
|
-
controller:
|
|
57
|
-
isUsingProxy:
|
|
58
|
-
request:
|
|
58
|
+
controller: p,
|
|
59
|
+
isUsingProxy: R,
|
|
60
|
+
request: S
|
|
59
61
|
}
|
|
60
62
|
];
|
|
61
|
-
} catch (
|
|
62
|
-
return [
|
|
63
|
+
} catch (n) {
|
|
64
|
+
return [D(n, h.BUILDING_REQUEST_FAILED), null];
|
|
63
65
|
}
|
|
64
66
|
};
|
|
65
67
|
export {
|
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
import type { HarRequest } from '@scalar/snippetz';
|
|
2
|
+
type HarToFetchRequestProps = {
|
|
3
|
+
/** The HAR Request object to convert */
|
|
4
|
+
harRequest: HarRequest;
|
|
5
|
+
};
|
|
6
|
+
/**
|
|
7
|
+
* Converts a HAR (HTTP Archive) Request to a Fetch API Request object.
|
|
8
|
+
*
|
|
9
|
+
* This function is the reverse of fetchRequestToHar - it takes a HAR request
|
|
10
|
+
* and converts it into a standard JavaScript Fetch API Request object.
|
|
11
|
+
*
|
|
12
|
+
* The conversion handles:
|
|
13
|
+
* - Request method and URL reconstruction
|
|
14
|
+
* - Headers reconstruction from HAR headers array
|
|
15
|
+
* - Cookies conversion to Cookie header
|
|
16
|
+
* - Form data (params) conversion to FormData or URLSearchParams
|
|
17
|
+
* - Body decoding
|
|
18
|
+
* - Content-Type and other header restoration
|
|
19
|
+
* - Query parameters (already embedded in the URL)
|
|
20
|
+
*
|
|
21
|
+
* Use cases:
|
|
22
|
+
* - Replaying recorded HTTP requests
|
|
23
|
+
* - Creating mock requests from HAR files
|
|
24
|
+
* - Testing with fixtures
|
|
25
|
+
* - Request caching and restoration
|
|
26
|
+
* - Re-executing historical API calls
|
|
27
|
+
*
|
|
28
|
+
* Note: The Fetch API Request object does not support setting the HTTP version,
|
|
29
|
+
* so that information from the HAR is not preserved in the returned Request.
|
|
30
|
+
* Query parameters are expected to be already part of the URL in the HAR.
|
|
31
|
+
*
|
|
32
|
+
* @see https://w3c.github.io/web-performance/specs/HAR/Overview.html
|
|
33
|
+
* @see https://developer.mozilla.org/en-US/docs/Web/API/Request
|
|
34
|
+
*
|
|
35
|
+
* @example
|
|
36
|
+
* const harRequest = { method: 'POST', url: 'https://api.example.com', ... }
|
|
37
|
+
* const request = harToFetchRequest({ harRequest })
|
|
38
|
+
* const response = await fetch(request)
|
|
39
|
+
*/
|
|
40
|
+
export declare const harToFetchRequest: ({ harRequest }: HarToFetchRequestProps) => Request;
|
|
41
|
+
export {};
|
|
42
|
+
//# sourceMappingURL=har-to-fetch-request.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"har-to-fetch-request.d.ts","sourceRoot":"","sources":["../../../../../src/v2/blocks/operation-block/helpers/har-to-fetch-request.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,kBAAkB,CAAA;AAElD,KAAK,sBAAsB,GAAG;IAC5B,wCAAwC;IACxC,UAAU,EAAE,UAAU,CAAA;CACvB,CAAA;AAED;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAiCG;AACH,eAAO,MAAM,iBAAiB,GAAI,gBAAgB,sBAAsB,KAAG,OAS1E,CAAA"}
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
const l = ({ harRequest: e }) => {
|
|
2
|
+
const n = s(e), o = d(e.postData);
|
|
3
|
+
return new Request(e.url, {
|
|
4
|
+
method: e.method,
|
|
5
|
+
headers: n,
|
|
6
|
+
body: o
|
|
7
|
+
});
|
|
8
|
+
}, s = (e) => {
|
|
9
|
+
const n = new Headers();
|
|
10
|
+
if (e.headers.forEach(({ name: o, value: t }) => {
|
|
11
|
+
n.append(o, t);
|
|
12
|
+
}), e.cookies?.length) {
|
|
13
|
+
const o = e.cookies.map(({ name: t, value: r }) => `${t}=${r}`).join("; ");
|
|
14
|
+
n.append("Cookie", o);
|
|
15
|
+
}
|
|
16
|
+
return n;
|
|
17
|
+
}, d = (e) => {
|
|
18
|
+
if (!e)
|
|
19
|
+
return null;
|
|
20
|
+
const { params: n, text: o, mimeType: t } = e;
|
|
21
|
+
if (n?.length) {
|
|
22
|
+
const c = t?.includes("multipart/form-data") ? new FormData() : new URLSearchParams();
|
|
23
|
+
return n.forEach(({ name: a, value: i }) => {
|
|
24
|
+
c.append(a, i || "");
|
|
25
|
+
}), c;
|
|
26
|
+
}
|
|
27
|
+
return o ? new TextEncoder().encode(o) : null;
|
|
28
|
+
};
|
|
29
|
+
export {
|
|
30
|
+
l as harToFetchRequest
|
|
31
|
+
};
|
|
@@ -0,0 +1,66 @@
|
|
|
1
|
+
import type { HttpMethod } from '@scalar/helpers/http/http-methods';
|
|
2
|
+
import type { HarResponse } from '@scalar/snippetz';
|
|
3
|
+
import type { ResponseInstance } from '../../../../v2/blocks/operation-block/helpers/send-request.js';
|
|
4
|
+
type HarToFetchResponseProps = {
|
|
5
|
+
/** The HAR Response object to convert */
|
|
6
|
+
harResponse: HarResponse;
|
|
7
|
+
/** Optional URL to set on the Response object */
|
|
8
|
+
url?: string;
|
|
9
|
+
/** The HTTP method used for the request */
|
|
10
|
+
method: HttpMethod;
|
|
11
|
+
/** The request path */
|
|
12
|
+
path: string;
|
|
13
|
+
/** Time in ms the request took */
|
|
14
|
+
duration?: number;
|
|
15
|
+
};
|
|
16
|
+
/**
|
|
17
|
+
* Converts a HAR (HTTP Archive) Response back to a ResponseInstance object.
|
|
18
|
+
*
|
|
19
|
+
* This function is the reverse of fetchResponseToHar - it takes a HAR response
|
|
20
|
+
* and converts it back into a ResponseInstance object that includes both the
|
|
21
|
+
* standard Fetch API Response properties and additional metadata.
|
|
22
|
+
*
|
|
23
|
+
* The conversion handles:
|
|
24
|
+
* - Status code and status text restoration
|
|
25
|
+
* - Headers reconstruction from HAR headers array
|
|
26
|
+
* - Body decoding
|
|
27
|
+
* - Content-Type and other header restoration
|
|
28
|
+
* - URL property setting (if provided)
|
|
29
|
+
* - Cookie header detection
|
|
30
|
+
* - Duration tracking
|
|
31
|
+
* - Response size calculation in bytes
|
|
32
|
+
*
|
|
33
|
+
* Body Handling:
|
|
34
|
+
* - Plain text (no encoding): Text-based responses under 1MB from fetchResponseToHar
|
|
35
|
+
* - Base64 encoded: Binary or legacy data (note: new HAR files won't contain binary data)
|
|
36
|
+
* - Empty: Streaming responses, large responses (>1MB), or responses without bodies
|
|
37
|
+
*
|
|
38
|
+
* Use cases:
|
|
39
|
+
* - Replaying recorded HTTP responses
|
|
40
|
+
* - Creating mock responses from HAR files
|
|
41
|
+
* - Testing with fixtures
|
|
42
|
+
* - Response caching and restoration
|
|
43
|
+
*
|
|
44
|
+
* Note: The Fetch API Response object does not support setting the HTTP version,
|
|
45
|
+
* so that information from the HAR is not preserved in the returned Response.
|
|
46
|
+
* The URL property is set using Object.defineProperty since it is read-only
|
|
47
|
+
* in the standard Response constructor.
|
|
48
|
+
*
|
|
49
|
+
* @see https://w3c.github.io/web-performance/specs/HAR/Overview.html
|
|
50
|
+
* @see https://developer.mozilla.org/en-US/docs/Web/API/Response
|
|
51
|
+
*
|
|
52
|
+
* @example
|
|
53
|
+
* const harResponse = { status: 200, statusText: 'OK', ... }
|
|
54
|
+
* const response = harToFetchResponse({
|
|
55
|
+
* harResponse,
|
|
56
|
+
* url: 'https://api.example.com',
|
|
57
|
+
* method: 'GET',
|
|
58
|
+
* path: '/users',
|
|
59
|
+
* duration: 250
|
|
60
|
+
* })
|
|
61
|
+
* console.log(response.url) // 'https://api.example.com'
|
|
62
|
+
* console.log(response.duration) // 250
|
|
63
|
+
*/
|
|
64
|
+
export declare const harToFetchResponse: ({ harResponse, url, method, path, duration, }: HarToFetchResponseProps) => ResponseInstance;
|
|
65
|
+
export {};
|
|
66
|
+
//# sourceMappingURL=har-to-fetch-response.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"har-to-fetch-response.d.ts","sourceRoot":"","sources":["../../../../../src/v2/blocks/operation-block/helpers/har-to-fetch-response.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,mCAAmC,CAAA;AACnE,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,kBAAkB,CAAA;AAGnD,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,kDAAkD,CAAA;AAExF,KAAK,uBAAuB,GAAG;IAC7B,yCAAyC;IACzC,WAAW,EAAE,WAAW,CAAA;IACxB,iDAAiD;IACjD,GAAG,CAAC,EAAE,MAAM,CAAA;IACZ,2CAA2C;IAC3C,MAAM,EAAE,UAAU,CAAA;IAClB,uBAAuB;IACvB,IAAI,EAAE,MAAM,CAAA;IACZ,kCAAkC;IAClC,QAAQ,CAAC,EAAE,MAAM,CAAA;CAClB,CAAA;AAWD;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA+CG;AACH,eAAO,MAAM,kBAAkB,GAAI,+CAMhC,uBAAuB,KAAG,gBAwB5B,CAAA"}
|
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
import { getCookieHeaderKeys as i } from "./get-cookie-header-keys.js";
|
|
2
|
+
const l = ({
|
|
3
|
+
harResponse: t,
|
|
4
|
+
url: e = "",
|
|
5
|
+
method: n,
|
|
6
|
+
path: s,
|
|
7
|
+
duration: r = 0
|
|
8
|
+
}) => {
|
|
9
|
+
const o = b(t), { body: d, data: a, size: c } = x(t), u = i(o);
|
|
10
|
+
return {
|
|
11
|
+
...new Response(d, {
|
|
12
|
+
status: t.status,
|
|
13
|
+
statusText: t.statusText,
|
|
14
|
+
headers: o
|
|
15
|
+
}),
|
|
16
|
+
headers: Object.fromEntries(o.entries()),
|
|
17
|
+
cookieHeaderKeys: u,
|
|
18
|
+
duration: r,
|
|
19
|
+
status: t.status,
|
|
20
|
+
statusText: t.statusText,
|
|
21
|
+
method: n,
|
|
22
|
+
path: s,
|
|
23
|
+
data: a,
|
|
24
|
+
size: c,
|
|
25
|
+
url: e
|
|
26
|
+
};
|
|
27
|
+
}, b = (t) => {
|
|
28
|
+
const e = new Headers();
|
|
29
|
+
return t.headers.forEach(({ name: n, value: s }) => {
|
|
30
|
+
e.append(n, s);
|
|
31
|
+
}), e;
|
|
32
|
+
}, x = (t) => {
|
|
33
|
+
if (!t.content.text)
|
|
34
|
+
return { body: null, data: "", size: 0 };
|
|
35
|
+
const { text: e, encoding: n } = t.content;
|
|
36
|
+
if (n)
|
|
37
|
+
return { body: null, data: e, size: e.length };
|
|
38
|
+
const s = new TextEncoder().encode(e).buffer;
|
|
39
|
+
return { body: s, data: e, size: s.byteLength };
|
|
40
|
+
};
|
|
41
|
+
export {
|
|
42
|
+
l as harToFetchResponse
|
|
43
|
+
};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"send-request.d.ts","sourceRoot":"","sources":["../../../../../src/v2/blocks/operation-block/helpers/send-request.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,mCAAmC,CAAA;AAEnE,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,8DAA8D,CAAA;AAEnG,OAAO,EAAU,KAAK,aAAa,EAAkB,MAAM,eAAe,CAAA;AAE1E,OAAO,EAAE,KAAK,YAAY,EAAe,MAAM,sBAAsB,CAAA;AAKrE,0DAA0D;AAC1D,MAAM,MAAM,gBAAgB,GAAG,IAAI,CAAC,QAAQ,EAAE,SAAS,CAAC,GAAG;IACzD,iEAAiE;IACjE,OAAO,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAA;IAC/B,wCAAwC;IACxC,gBAAgB,EAAE,MAAM,EAAE,CAAA;IAC1B,kCAAkC;IAClC,QAAQ,EAAE,MAAM,CAAA;IAChB,0BAA0B;IAC1B,MAAM,EAAE,MAAM,CAAA;IACd,+BAA+B;IAC/B,UAAU,EAAE,MAAM,CAAA;IAClB,0BAA0B;IAC1B,MAAM,EAAE,UAAU,CAAA;IAClB,uBAAuB;IACvB,IAAI,EAAE,MAAM,CAAA;CACb,GAAG,CACE;IACE,wBAAwB;IACxB,IAAI,EAAE,MAAM,GAAG,IAAI,CAAA;IACnB,iCAAiC;IACjC,IAAI,EAAE,MAAM,CAAA;CACb,GACD;IACE,qDAAqD;IACrD,MAAM,EAAE,2BAA2B,CAAC,UAAU,CAAC,CAAA;CAChD,CACJ,CAAA;AAKH;;;;;;;;;;;;GAYG;AACH,eAAO,MAAM,WAAW,GAAU,gDAK/B;IACD,YAAY,EAAE,OAAO,CAAA;IACrB,SAAS,EAAE,eAAe,CAAA;IAC1B,OAAO,EAAE,YAAY,EAAE,CAAA;IACvB,OAAO,EAAE,OAAO,CAAA;CACjB,KAAG,OAAO,CACT,aAAa,CAAC;IACZ,QAAQ,EAAE,gBAAgB,CAAA;IAC1B,OAAO,EAAE,OAAO,CAAA;IAChB,SAAS,EAAE,MAAM,CAAA;
|
|
1
|
+
{"version":3,"file":"send-request.d.ts","sourceRoot":"","sources":["../../../../../src/v2/blocks/operation-block/helpers/send-request.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,mCAAmC,CAAA;AAEnE,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,8DAA8D,CAAA;AAEnG,OAAO,EAAU,KAAK,aAAa,EAAkB,MAAM,eAAe,CAAA;AAE1E,OAAO,EAAE,KAAK,YAAY,EAAe,MAAM,sBAAsB,CAAA;AAKrE,0DAA0D;AAC1D,MAAM,MAAM,gBAAgB,GAAG,IAAI,CAAC,QAAQ,EAAE,SAAS,CAAC,GAAG;IACzD,iEAAiE;IACjE,OAAO,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAA;IAC/B,wCAAwC;IACxC,gBAAgB,EAAE,MAAM,EAAE,CAAA;IAC1B,kCAAkC;IAClC,QAAQ,EAAE,MAAM,CAAA;IAChB,0BAA0B;IAC1B,MAAM,EAAE,MAAM,CAAA;IACd,+BAA+B;IAC/B,UAAU,EAAE,MAAM,CAAA;IAClB,0BAA0B;IAC1B,MAAM,EAAE,UAAU,CAAA;IAClB,uBAAuB;IACvB,IAAI,EAAE,MAAM,CAAA;CACb,GAAG,CACE;IACE,wBAAwB;IACxB,IAAI,EAAE,MAAM,GAAG,IAAI,CAAA;IACnB,iCAAiC;IACjC,IAAI,EAAE,MAAM,CAAA;CACb,GACD;IACE,qDAAqD;IACrD,MAAM,EAAE,2BAA2B,CAAC,UAAU,CAAC,CAAA;CAChD,CACJ,CAAA;AAKH;;;;;;;;;;;;GAYG;AACH,eAAO,MAAM,WAAW,GAAU,gDAK/B;IACD,YAAY,EAAE,OAAO,CAAA;IACrB,SAAS,EAAE,eAAe,CAAA;IAC1B,OAAO,EAAE,YAAY,EAAE,CAAA;IACvB,OAAO,EAAE,OAAO,CAAA;CACjB,KAAG,OAAO,CACT,aAAa,CAAC;IACZ,QAAQ,EAAE,gBAAgB,CAAA;IAC1B,OAAO,EAAE,OAAO,CAAA;IAChB,SAAS,EAAE,MAAM,CAAA;IACjB,gBAAgB,EAAE,QAAQ,CAAA;CAC3B,CAAC,CA0DH,CAAA"}
|
|
@@ -6,47 +6,47 @@ import { decodeBuffer as D } from "./decode-buffer.js";
|
|
|
6
6
|
import { getCookieHeaderKeys as T } from "./get-cookie-header-keys.js";
|
|
7
7
|
const E = [204, 205, 304], v = async ({
|
|
8
8
|
isUsingProxy: t,
|
|
9
|
-
operation:
|
|
10
|
-
request:
|
|
11
|
-
plugins:
|
|
9
|
+
operation: n,
|
|
10
|
+
request: p,
|
|
11
|
+
plugins: r
|
|
12
12
|
}) => {
|
|
13
13
|
try {
|
|
14
|
-
const { request: s } = await f({ request:
|
|
14
|
+
const { request: s } = await f({ request: p }, "beforeRequest", r), l = Date.now(), e = await fetch(s.clone()), a = Date.now(), c = a - l, d = e.headers.get("content-type"), o = x(e.headers, t), u = new URL(e.url), m = u.pathname + u.search, i = e.statusText || S[e.status]?.name || "", h = s.method, R = E.includes(e.status);
|
|
15
15
|
return d?.startsWith("text/event-stream") && e.body ? H({
|
|
16
16
|
response: e,
|
|
17
17
|
modifiedRequest: s,
|
|
18
|
-
operation:
|
|
19
|
-
plugins:
|
|
18
|
+
operation: n,
|
|
19
|
+
plugins: r,
|
|
20
20
|
endTime: a,
|
|
21
21
|
duration: c,
|
|
22
22
|
responseHeaders: o,
|
|
23
|
-
statusText:
|
|
24
|
-
method:
|
|
25
|
-
fullPath:
|
|
26
|
-
}) :
|
|
23
|
+
statusText: i,
|
|
24
|
+
method: h,
|
|
25
|
+
fullPath: m
|
|
26
|
+
}) : g({
|
|
27
27
|
response: e,
|
|
28
28
|
modifiedRequest: s,
|
|
29
|
-
operation:
|
|
30
|
-
plugins:
|
|
29
|
+
operation: n,
|
|
30
|
+
plugins: r,
|
|
31
31
|
endTime: a,
|
|
32
32
|
duration: c,
|
|
33
33
|
responseHeaders: o,
|
|
34
|
-
statusText:
|
|
35
|
-
method:
|
|
36
|
-
fullPath:
|
|
34
|
+
statusText: i,
|
|
35
|
+
method: h,
|
|
36
|
+
fullPath: m,
|
|
37
37
|
contentType: d,
|
|
38
|
-
shouldSkipBody:
|
|
38
|
+
shouldSkipBody: R
|
|
39
39
|
});
|
|
40
40
|
} catch (s) {
|
|
41
41
|
return [b(s, q.REQUEST_FAILED), null];
|
|
42
42
|
}
|
|
43
43
|
}, H = async ({
|
|
44
44
|
response: t,
|
|
45
|
-
modifiedRequest:
|
|
46
|
-
operation:
|
|
47
|
-
plugins:
|
|
45
|
+
modifiedRequest: n,
|
|
46
|
+
operation: p,
|
|
47
|
+
plugins: r,
|
|
48
48
|
endTime: s,
|
|
49
|
-
duration:
|
|
49
|
+
duration: l,
|
|
50
50
|
responseHeaders: e,
|
|
51
51
|
statusText: a,
|
|
52
52
|
method: c,
|
|
@@ -57,31 +57,32 @@ const E = [204, 205, 304], v = async ({
|
|
|
57
57
|
statusText: a,
|
|
58
58
|
headers: t.headers
|
|
59
59
|
});
|
|
60
|
-
await f({ response: o, request:
|
|
60
|
+
await f({ response: o, request: n, operation: p }, "responseReceived", r);
|
|
61
61
|
const u = T(o.headers);
|
|
62
62
|
return [
|
|
63
63
|
null,
|
|
64
64
|
{
|
|
65
65
|
timestamp: s,
|
|
66
|
-
request:
|
|
66
|
+
request: n,
|
|
67
67
|
response: {
|
|
68
68
|
...o,
|
|
69
69
|
headers: e,
|
|
70
70
|
cookieHeaderKeys: u,
|
|
71
71
|
reader: t.body.getReader(),
|
|
72
|
-
duration:
|
|
72
|
+
duration: l,
|
|
73
73
|
method: c,
|
|
74
74
|
path: d
|
|
75
|
-
}
|
|
75
|
+
},
|
|
76
|
+
originalResponse: o.clone()
|
|
76
77
|
}
|
|
77
78
|
];
|
|
78
|
-
},
|
|
79
|
+
}, g = async ({
|
|
79
80
|
response: t,
|
|
80
|
-
modifiedRequest:
|
|
81
|
-
operation:
|
|
82
|
-
plugins:
|
|
81
|
+
modifiedRequest: n,
|
|
82
|
+
operation: p,
|
|
83
|
+
plugins: r,
|
|
83
84
|
endTime: s,
|
|
84
|
-
duration:
|
|
85
|
+
duration: l,
|
|
85
86
|
responseHeaders: e,
|
|
86
87
|
statusText: a,
|
|
87
88
|
method: c,
|
|
@@ -89,29 +90,30 @@ const E = [204, 205, 304], v = async ({
|
|
|
89
90
|
contentType: o,
|
|
90
91
|
shouldSkipBody: u
|
|
91
92
|
}) => {
|
|
92
|
-
const
|
|
93
|
+
const i = await t.clone().arrayBuffer(), R = D(i, o ?? "text/plain;charset=UTF-8"), y = new Response(u ? null : i, {
|
|
93
94
|
status: t.status,
|
|
94
95
|
statusText: a,
|
|
95
96
|
headers: t.headers
|
|
96
97
|
});
|
|
97
|
-
await f({ response:
|
|
98
|
-
const w = T(
|
|
98
|
+
await f({ response: y, request: n, operation: p }, "responseReceived", r);
|
|
99
|
+
const w = T(y.headers);
|
|
99
100
|
return [
|
|
100
101
|
null,
|
|
101
102
|
{
|
|
102
103
|
timestamp: s,
|
|
103
|
-
request:
|
|
104
|
+
request: n,
|
|
104
105
|
response: {
|
|
105
|
-
...
|
|
106
|
+
...y,
|
|
106
107
|
headers: e,
|
|
107
108
|
cookieHeaderKeys: w,
|
|
108
|
-
data:
|
|
109
|
-
size:
|
|
110
|
-
duration:
|
|
109
|
+
data: R,
|
|
110
|
+
size: i.byteLength,
|
|
111
|
+
duration: l,
|
|
111
112
|
method: c,
|
|
112
113
|
status: t.status,
|
|
113
114
|
path: d
|
|
114
|
-
}
|
|
115
|
+
},
|
|
116
|
+
originalResponse: t.clone()
|
|
115
117
|
}
|
|
116
118
|
];
|
|
117
119
|
};
|