@scalar/api-client 2.2.11 → 2.2.15
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 +57 -0
- package/dist/components/AddressBar/AddressBar.vue.d.ts.map +1 -1
- package/dist/components/AddressBar/AddressBar.vue.js +2 -2
- package/dist/components/AddressBar/AddressBar.vue2.js +114 -111
- package/dist/components/AddressBar/AddressBarServer.vue.d.ts.map +1 -1
- package/dist/components/AddressBar/AddressBarServer.vue.js +74 -81
- package/dist/components/AddressBar/AddressBarServerItem.vue.d.ts.map +1 -1
- package/dist/components/AddressBar/AddressBarServerItem.vue.js +19 -18
- package/dist/components/SideNav/SideNav.vue.js +6 -6
- package/dist/components/Sidebar/Sidebar.vue.js +2 -2
- package/dist/components/Sidebar/Sidebar.vue2.js +1 -1
- package/dist/components/ViewLayout/ViewLayoutSection.vue.js +3 -3
- package/dist/layouts/App/create-api-client-app.d.ts +1 -1
- package/dist/layouts/Modal/ApiClientModal.vue.d.ts.map +1 -1
- package/dist/layouts/Modal/ApiClientModal.vue.js +2 -2
- package/dist/layouts/Modal/create-api-client-modal.d.ts +2 -2
- package/dist/layouts/Web/create-api-client-web.d.ts +1 -1
- package/dist/libs/create-client.d.ts +1 -1
- package/dist/libs/create-client.d.ts.map +1 -1
- package/dist/libs/create-client.js +64 -51
- package/dist/libs/send-request/send-request.d.ts.map +1 -1
- package/dist/libs/send-request/send-request.js +47 -45
- package/dist/style.css +1 -1
- package/dist/views/Request/RequestSection/RequestAuth/RequestExampleAuth.vue.d.ts.map +1 -1
- package/dist/views/Request/RequestSection/RequestAuth/RequestExampleAuth.vue.js +1 -1
- package/dist/views/Request/RequestSection/RequestAuth/RequestExampleAuth.vue2.js +49 -48
- package/dist/views/Request/RequestSection/RequestPathParams.vue.d.ts.map +1 -1
- package/dist/views/Request/RequestSection/RequestPathParams.vue.js +53 -51
- package/dist/views/Request/RequestSection/RequestSection.vue.js +2 -2
- package/dist/views/Request/RequestSection/RequestSection.vue2.js +15 -15
- package/dist/views/Request/RequestSubpageHeader.vue.js +3 -3
- package/dist/views/Request/RequestSubpageHeader.vue2.js +1 -1
- package/dist/views/Request/ResponseSection/ResponseEmpty.vue2.js +1 -1
- package/package.json +11 -11
|
@@ -1,28 +1,28 @@
|
|
|
1
1
|
import { ERRORS as v, normalizeError as B } from "../errors.js";
|
|
2
|
-
import { normalizeHeaders as
|
|
2
|
+
import { normalizeHeaders as $ } from "../normalize-headers.js";
|
|
3
3
|
import { replaceTemplateVariables as f } from "../string-template.js";
|
|
4
|
-
import { canMethodHaveBody as
|
|
4
|
+
import { canMethodHaveBody as q, isRelativePath as C, concatenateUrlAndPath as F, shouldUseProxy as U, REGEX as H } from "@scalar/oas-utils/helpers";
|
|
5
5
|
import g from "js-cookie";
|
|
6
6
|
import M from "whatwg-mimetype";
|
|
7
7
|
import { textMediaTypes as z } from "../../views/Request/consts/mediaTypes.js";
|
|
8
|
-
function
|
|
8
|
+
function K(n, o) {
|
|
9
9
|
const t = new M(o);
|
|
10
10
|
return z.includes(t.essence) ? new TextDecoder(t.parameters.get("charset")).decode(n) : new Blob([n], { type: t.essence });
|
|
11
11
|
}
|
|
12
|
-
function
|
|
12
|
+
function W(n, o) {
|
|
13
13
|
const t = {};
|
|
14
14
|
return n.parameters.headers.forEach((r) => {
|
|
15
15
|
const h = r.key.trim().toLowerCase();
|
|
16
16
|
r.enabled && (h !== "content-type" || r.value !== "multipart/form-data") && (t[h] = f(r.value, o));
|
|
17
17
|
}), t;
|
|
18
18
|
}
|
|
19
|
-
function
|
|
19
|
+
function j(n, o) {
|
|
20
20
|
const t = new URLSearchParams();
|
|
21
21
|
return n.parameters.query.forEach((r) => {
|
|
22
22
|
r.enabled && r.value && t.append(r.key, f(r.value, o));
|
|
23
23
|
}), t;
|
|
24
24
|
}
|
|
25
|
-
function
|
|
25
|
+
function N({
|
|
26
26
|
example: n,
|
|
27
27
|
env: o,
|
|
28
28
|
globalCookies: t,
|
|
@@ -42,13 +42,13 @@ function j({
|
|
|
42
42
|
sameSite: "None",
|
|
43
43
|
// The Secure attribute must also be set when setting SameSite=None.
|
|
44
44
|
secure: !0
|
|
45
|
-
},
|
|
46
|
-
return Object.keys(
|
|
45
|
+
}, y = g.get();
|
|
46
|
+
return Object.keys(y).forEach((a) => g.remove(a)), n.parameters.cookies.forEach((a) => {
|
|
47
47
|
a.enabled && g.set(a.key, f(a.value, o));
|
|
48
48
|
}), t.forEach((a) => {
|
|
49
|
-
var
|
|
50
|
-
const { name: c, value:
|
|
51
|
-
(p.domain === r || ((
|
|
49
|
+
var l;
|
|
50
|
+
const { name: c, value: k, ...p } = a;
|
|
51
|
+
(p.domain === r || ((l = p.domain) == null ? void 0 : l.startsWith(".")) && r.endsWith(p.domain ?? "")) && g.set(c, k, {
|
|
52
52
|
/** Override the domain with the proxy value */
|
|
53
53
|
domain: m,
|
|
54
54
|
// TODO: path cookies probably don't worth with the proxy
|
|
@@ -61,15 +61,15 @@ function j({
|
|
|
61
61
|
cookieParams: i
|
|
62
62
|
};
|
|
63
63
|
}
|
|
64
|
-
function
|
|
64
|
+
function Y(n, o, t) {
|
|
65
65
|
var r, h, m;
|
|
66
|
-
if (!
|
|
66
|
+
if (!q(n))
|
|
67
67
|
return { body: void 0, contentType: void 0 };
|
|
68
68
|
if (o.body.activeBody === "formData" && o.body.formData) {
|
|
69
|
-
const i = o.body.formData.encoding === "form-data" ? "multipart/form-data" : "application/x-www-form-urlencoded",
|
|
69
|
+
const i = o.body.formData.encoding === "form-data" ? "multipart/form-data" : "application/x-www-form-urlencoded", y = o.body.formData.encoding === "form-data" ? new FormData() : new URLSearchParams();
|
|
70
70
|
return o.body.formData.value.forEach((a) => {
|
|
71
|
-
!a.enabled || !a.key || (a.file &&
|
|
72
|
-
}), { body:
|
|
71
|
+
!a.enabled || !a.key || (a.file && y instanceof FormData ? y.append(a.key, a.file, a.file.name) : a.value !== void 0 && y.append(a.key, f(a.value, t)));
|
|
72
|
+
}), { body: y, contentType: i };
|
|
73
73
|
}
|
|
74
74
|
return o.body.activeBody === "raw" ? {
|
|
75
75
|
body: f(((r = o.body.raw) == null ? void 0 : r.value) ?? "", t),
|
|
@@ -82,10 +82,10 @@ function N(n, o, t) {
|
|
|
82
82
|
contentType: void 0
|
|
83
83
|
};
|
|
84
84
|
}
|
|
85
|
-
function
|
|
86
|
-
return n.startsWith("http://") || n.startsWith("https://") ? n : `http://${n}`;
|
|
85
|
+
function Q(n) {
|
|
86
|
+
return H.PATH.test(n) || n.startsWith("http://") || n.startsWith("https://") ? n : `http://${n}`;
|
|
87
87
|
}
|
|
88
|
-
const T = "YOUR_SECRET_TOKEN",
|
|
88
|
+
const T = "YOUR_SECRET_TOKEN", oe = ({
|
|
89
89
|
request: n,
|
|
90
90
|
example: o,
|
|
91
91
|
server: t,
|
|
@@ -93,18 +93,20 @@ const T = "YOUR_SECRET_TOKEN", ee = ({
|
|
|
93
93
|
selectedSecuritySchemeUids: h = [],
|
|
94
94
|
proxyUrl: m,
|
|
95
95
|
status: i,
|
|
96
|
-
environment:
|
|
96
|
+
environment: y,
|
|
97
97
|
globalCookies: a
|
|
98
98
|
}) => {
|
|
99
99
|
try {
|
|
100
|
-
const c =
|
|
101
|
-
let d = P ||
|
|
100
|
+
const c = y ?? {}, k = new AbortController(), p = o.parameters.path.reduce((u, e) => (e.enabled && (u[e.key] = f(e.value, c)), u), {}), P = f((t == null ? void 0 : t.url) ?? "", c), l = f(n.path, p);
|
|
101
|
+
let d = P || l;
|
|
102
102
|
if (!d) throw v.URL_EMPTY;
|
|
103
103
|
Object.entries((t == null ? void 0 : t.variables) ?? {}).forEach(([u, e]) => {
|
|
104
|
-
d = f(d, {
|
|
104
|
+
d = f(d, {
|
|
105
|
+
[u]: p[u] || e.default
|
|
106
|
+
});
|
|
105
107
|
});
|
|
106
|
-
const D =
|
|
107
|
-
if (
|
|
108
|
+
const D = j(o, c), E = W(o, c), { body: O } = Y(n.method, o, c);
|
|
109
|
+
if (N({
|
|
108
110
|
example: o,
|
|
109
111
|
env: c,
|
|
110
112
|
globalCookies: a,
|
|
@@ -116,33 +118,33 @@ const T = "YOUR_SECRET_TOKEN", ee = ({
|
|
|
116
118
|
if (e) {
|
|
117
119
|
if (e.type === "apiKey") {
|
|
118
120
|
const s = f(e.value, c) || T;
|
|
119
|
-
e.in === "header" && (
|
|
121
|
+
e.in === "header" && (E[e.name] = s), e.in === "query" && D.append(e.name, s), e.in === "cookie" && g.set(e.name, s);
|
|
120
122
|
}
|
|
121
123
|
if (e.type === "http")
|
|
122
124
|
if (e.scheme === "basic") {
|
|
123
125
|
const s = f(e.username, c), b = f(e.password, c), R = `${s}:${b}`;
|
|
124
|
-
|
|
126
|
+
E.Authorization = `Basic ${R === ":" ? "username:password" : btoa(R)}`;
|
|
125
127
|
} else {
|
|
126
128
|
const s = f(e.token, c);
|
|
127
|
-
|
|
129
|
+
E.Authorization = `Bearer ${s || T}`;
|
|
128
130
|
}
|
|
129
131
|
if (e.type === "oauth2") {
|
|
130
132
|
const b = (w = Object.values(e.flows).find((R) => R.token)) == null ? void 0 : w.token;
|
|
131
|
-
|
|
133
|
+
E.Authorization = `Bearer ${b || T}`;
|
|
132
134
|
}
|
|
133
135
|
}
|
|
134
136
|
}), d && (!C(d) || typeof window < "u")) {
|
|
135
|
-
const u = C(d) ? F(window.location.origin, d) :
|
|
136
|
-
t != null && t.url && (e.pathname === "/" ? s.pathname =
|
|
137
|
+
const u = C(d) ? F(window.location.origin, d) : Q(d), e = new URL(u), w = new URL(l, e.origin), s = new URL(e);
|
|
138
|
+
t != null && t.url && (e.pathname === "/" ? s.pathname = l : s.pathname = e.pathname + l), s.search = new URLSearchParams([
|
|
137
139
|
...e.searchParams,
|
|
138
140
|
...w.searchParams,
|
|
139
141
|
...D
|
|
140
142
|
]).toString(), d = s.toString();
|
|
141
143
|
}
|
|
142
|
-
const S = new URLSearchParams([["scalar_url", d.toString()]]),
|
|
144
|
+
const S = new URLSearchParams([["scalar_url", d.toString()]]), A = U(m, d) ? `${m}?${S.toString()}` : d, L = new Request(A, {
|
|
143
145
|
method: n.method.toUpperCase(),
|
|
144
146
|
body: O,
|
|
145
|
-
headers:
|
|
147
|
+
headers: E
|
|
146
148
|
});
|
|
147
149
|
return [
|
|
148
150
|
null,
|
|
@@ -153,13 +155,13 @@ const T = "YOUR_SECRET_TOKEN", ee = ({
|
|
|
153
155
|
const u = Date.now();
|
|
154
156
|
try {
|
|
155
157
|
const e = await fetch(L, {
|
|
156
|
-
signal:
|
|
158
|
+
signal: k.signal
|
|
157
159
|
});
|
|
158
160
|
i == null || i.emit("stop");
|
|
159
|
-
const w =
|
|
161
|
+
const w = $(
|
|
160
162
|
e.headers,
|
|
161
163
|
U(m, d)
|
|
162
|
-
), s = e.headers.get("content-type") ?? "text/plain;charset=UTF-8", b = await e.arrayBuffer(), R =
|
|
164
|
+
), s = e.headers.get("content-type") ?? "text/plain;charset=UTF-8", b = await e.arrayBuffer(), R = K(b, s), _ = "getSetCookie" in e.headers && typeof e.headers.getSetCookie == "function" ? e.headers.getSetCookie() : [];
|
|
163
165
|
return [
|
|
164
166
|
null,
|
|
165
167
|
{
|
|
@@ -168,13 +170,13 @@ const T = "YOUR_SECRET_TOKEN", ee = ({
|
|
|
168
170
|
response: {
|
|
169
171
|
...e,
|
|
170
172
|
headers: w,
|
|
171
|
-
cookieHeaderKeys:
|
|
173
|
+
cookieHeaderKeys: _,
|
|
172
174
|
data: R,
|
|
173
175
|
size: b.byteLength,
|
|
174
176
|
duration: Date.now() - u,
|
|
175
177
|
method: n.method,
|
|
176
178
|
status: e.status,
|
|
177
|
-
path:
|
|
179
|
+
path: l
|
|
178
180
|
}
|
|
179
181
|
}
|
|
180
182
|
];
|
|
@@ -182,7 +184,7 @@ const T = "YOUR_SECRET_TOKEN", ee = ({
|
|
|
182
184
|
return i == null || i.emit("abort"), [B(e, v.REQUEST_FAILED), null];
|
|
183
185
|
}
|
|
184
186
|
},
|
|
185
|
-
controller:
|
|
187
|
+
controller: k
|
|
186
188
|
}
|
|
187
189
|
];
|
|
188
190
|
} catch (c) {
|
|
@@ -190,10 +192,10 @@ const T = "YOUR_SECRET_TOKEN", ee = ({
|
|
|
190
192
|
}
|
|
191
193
|
};
|
|
192
194
|
export {
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
195
|
+
Y as createFetchBody,
|
|
196
|
+
W as createFetchHeaders,
|
|
197
|
+
j as createFetchQueryParams,
|
|
198
|
+
oe as createRequestOperation,
|
|
199
|
+
K as decodeBuffer,
|
|
200
|
+
N as setRequestCookies
|
|
199
201
|
};
|