@scalar/api-client 2.1.13 → 2.1.14
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 +8 -0
- package/dist/components/CommandPalette/CommandActionInput.vue.d.ts +4 -0
- package/dist/components/CommandPalette/CommandActionInput.vue.d.ts.map +1 -1
- package/dist/components/CommandPalette/CommandActionInput.vue.js +29 -24
- package/dist/components/CommandPalette/CommandPaletteImport.vue.d.ts.map +1 -1
- package/dist/components/CommandPalette/CommandPaletteImport.vue.js +90 -49
- package/dist/components/Sidebar/Sidebar.vue.d.ts.map +1 -1
- package/dist/components/Sidebar/Sidebar.vue.js +2 -2
- package/dist/components/Sidebar/Sidebar.vue2.js +25 -20
- package/dist/libs/getOpenApiDocumentVersion.d.ts +8 -0
- package/dist/libs/getOpenApiDocumentVersion.d.ts.map +1 -0
- package/dist/libs/getOpenApiDocumentVersion.js +20 -0
- package/dist/libs/index.d.ts +3 -0
- package/dist/libs/index.d.ts.map +1 -1
- package/dist/libs/index.js +29 -23
- package/dist/libs/isDocument.d.ts +3 -0
- package/dist/libs/isDocument.d.ts.map +1 -0
- package/dist/libs/isDocument.js +7 -0
- package/dist/libs/isUrl.d.ts +3 -0
- package/dist/libs/isUrl.d.ts.map +1 -0
- package/dist/libs/isUrl.js +6 -0
- package/dist/libs/send-request.js +41 -41
- package/dist/style.css +1 -1
- package/dist/views/Request/RequestSidebar.vue.d.ts.map +1 -1
- package/dist/views/Request/RequestSidebar.vue.js +3 -3
- package/dist/views/Request/RequestSidebar.vue2.js +49 -50
- package/dist/views/Request/ResponseSection/ResponseEmpty.vue2.js +1 -1
- package/package.json +6 -6
|
@@ -4,31 +4,31 @@ import { replaceTemplateVariables as u } from "./string-template.js";
|
|
|
4
4
|
import { isRelativePath as E, shouldUseProxy as B, canMethodHaveBody as z } from "@scalar/oas-utils/helpers";
|
|
5
5
|
import k from "js-cookie";
|
|
6
6
|
import H from "whatwg-mimetype";
|
|
7
|
-
import { requestStatusBus as
|
|
7
|
+
import { requestStatusBus as S } from "./event-busses/request-status-bus.js";
|
|
8
8
|
import { textMediaTypes as q } from "../views/Request/consts/mediaTypes.js";
|
|
9
|
-
function K(
|
|
9
|
+
function K(r, n) {
|
|
10
10
|
const o = new H(n);
|
|
11
11
|
if (q.includes(o.essence)) {
|
|
12
|
-
const c = new TextDecoder(o.parameters.get("charset")).decode(
|
|
12
|
+
const c = new TextDecoder(o.parameters.get("charset")).decode(r);
|
|
13
13
|
return o.subtype === "json" ? JSON.parse(c) : c;
|
|
14
14
|
}
|
|
15
|
-
return new Blob([
|
|
15
|
+
return new Blob([r], { type: o.essence });
|
|
16
16
|
}
|
|
17
|
-
function _(
|
|
17
|
+
function _(r, n) {
|
|
18
18
|
const o = {};
|
|
19
|
-
return
|
|
19
|
+
return r.parameters.headers.forEach((t) => {
|
|
20
20
|
const c = t.key.trim().toLowerCase();
|
|
21
21
|
t.enabled && (c !== "content-type" || t.value !== "multipart/form-data") && (o[c] = u(t.value, n));
|
|
22
22
|
}), o;
|
|
23
23
|
}
|
|
24
|
-
function j(
|
|
24
|
+
function j(r, n) {
|
|
25
25
|
const o = new URLSearchParams();
|
|
26
|
-
return
|
|
26
|
+
return r.parameters.query.forEach((t) => {
|
|
27
27
|
t.enabled && t.value && o.append(t.key, u(t.value, n));
|
|
28
28
|
}), o;
|
|
29
29
|
}
|
|
30
30
|
function N({
|
|
31
|
-
example:
|
|
31
|
+
example: r,
|
|
32
32
|
env: n,
|
|
33
33
|
globalCookies: o,
|
|
34
34
|
domain: t,
|
|
@@ -48,12 +48,12 @@ function N({
|
|
|
48
48
|
// The Secure attribute must also be set when setting SameSite=None.
|
|
49
49
|
secure: !0
|
|
50
50
|
}, f = k.get();
|
|
51
|
-
return Object.keys(f).forEach((e) => k.remove(e)),
|
|
51
|
+
return Object.keys(f).forEach((e) => k.remove(e)), r.parameters.cookies.forEach((e) => {
|
|
52
52
|
e.enabled && k.set(e.key, u(e.value, n));
|
|
53
53
|
}), o.forEach((e) => {
|
|
54
54
|
var i;
|
|
55
|
-
const { name: R, value:
|
|
56
|
-
(m.domain === t || ((i = m.domain) == null ? void 0 : i.startsWith(".")) && t.endsWith(m.domain ?? "")) && k.set(R,
|
|
55
|
+
const { name: R, value: v, ...m } = e;
|
|
56
|
+
(m.domain === t || ((i = m.domain) == null ? void 0 : i.startsWith(".")) && t.endsWith(m.domain ?? "")) && k.set(R, v, {
|
|
57
57
|
/** Override the domain with the proxy value */
|
|
58
58
|
domain: d,
|
|
59
59
|
// TODO: path cookies probably don't worth with the proxy
|
|
@@ -66,9 +66,9 @@ function N({
|
|
|
66
66
|
cookieParams: l
|
|
67
67
|
};
|
|
68
68
|
}
|
|
69
|
-
function Q(
|
|
69
|
+
function Q(r, n, o) {
|
|
70
70
|
var t, c, d;
|
|
71
|
-
if (!z(
|
|
71
|
+
if (!z(r))
|
|
72
72
|
return { body: void 0, contentType: void 0 };
|
|
73
73
|
if (n.body.activeBody === "formData" && n.body.formData) {
|
|
74
74
|
const l = n.body.formData.encoding === "form-data" ? "multipart/form-data" : "application/x-www-form-urlencoded", f = n.body.formData.encoding === "form-data" ? new FormData() : new URLSearchParams();
|
|
@@ -88,7 +88,7 @@ function Q(s, n, o) {
|
|
|
88
88
|
};
|
|
89
89
|
}
|
|
90
90
|
const te = ({
|
|
91
|
-
request:
|
|
91
|
+
request: r,
|
|
92
92
|
auth: n,
|
|
93
93
|
example: o,
|
|
94
94
|
server: t,
|
|
@@ -98,30 +98,30 @@ const te = ({
|
|
|
98
98
|
globalCookies: f
|
|
99
99
|
}) => {
|
|
100
100
|
try {
|
|
101
|
-
const e = l ?? {}, R = new AbortController(),
|
|
101
|
+
const e = l ?? {}, R = new AbortController(), v = o.parameters.path.reduce((p, a) => (a.enabled && (p[a.key] = u(a.value, e)), p), {}), m = u((t == null ? void 0 : t.url) ?? "", e), y = u(r.path, v);
|
|
102
102
|
let i = m || y;
|
|
103
103
|
if (!i) throw T.URL_EMPTY;
|
|
104
|
-
const P = j(o, e), w = _(o, e), { body: C } = Q(
|
|
104
|
+
const P = j(o, e), w = _(o, e), { body: C } = Q(r.method, o, e), { cookieParams: V } = N({
|
|
105
105
|
example: o,
|
|
106
106
|
env: e,
|
|
107
107
|
globalCookies: f,
|
|
108
108
|
domain: i,
|
|
109
109
|
proxy: d
|
|
110
110
|
});
|
|
111
|
-
return
|
|
111
|
+
return r.selectedSecuritySchemeUids.forEach((p) => {
|
|
112
112
|
const a = n[p], h = c[p];
|
|
113
113
|
if (!(!a || !h)) {
|
|
114
114
|
if (h.type === "apiKey" && a.type === "apiKey") {
|
|
115
|
-
const
|
|
116
|
-
h.in === "header" && (w[a.name] =
|
|
115
|
+
const s = u(a.value, e);
|
|
116
|
+
h.in === "header" && (w[a.name] = s), h.in === "query" && P.append(a.name, s), h.in === "cookie" && k.set(a.name, s);
|
|
117
117
|
}
|
|
118
118
|
if (h.type === "http" && a.type === "http")
|
|
119
119
|
if (h.scheme === "basic") {
|
|
120
|
-
const
|
|
120
|
+
const s = u(a.username, e), U = u(a.password, e), D = `${s}:${U}`;
|
|
121
121
|
w.Authorization = `Basic ${btoa(D)}`;
|
|
122
122
|
} else {
|
|
123
|
-
const
|
|
124
|
-
w.Authorization = `Bearer ${
|
|
123
|
+
const s = u(a.token, e);
|
|
124
|
+
w.Authorization = `Bearer ${s}`;
|
|
125
125
|
}
|
|
126
126
|
h.type === "oauth2" && a.type.includes("oauth") && "token" in a && (a.token || console.error("OAuth token was not created"), w.Authorization = `Bearer ${a.token}`);
|
|
127
127
|
}
|
|
@@ -129,57 +129,57 @@ const te = ({
|
|
|
129
129
|
null,
|
|
130
130
|
{
|
|
131
131
|
sendRequest: async () => {
|
|
132
|
-
|
|
132
|
+
S.emit("start");
|
|
133
133
|
const p = Date.now();
|
|
134
134
|
try {
|
|
135
135
|
if (i && (!E(i) || typeof window < "u")) {
|
|
136
|
-
const O = E(i) ? window.location.origin + i : i, b = new URL(O), $ = new URL(y, b.origin),
|
|
137
|
-
t != null && t.url && (b.pathname === "/" ?
|
|
136
|
+
const O = E(i) ? window.location.origin + i : i, b = new URL(O), $ = new URL(y, b.origin), g = new URL(b);
|
|
137
|
+
t != null && t.url && (b.pathname === "/" ? g.pathname = y : g.pathname = b.pathname + y), g.search = new URLSearchParams([
|
|
138
138
|
...b.searchParams,
|
|
139
139
|
...$.searchParams,
|
|
140
140
|
...P
|
|
141
|
-
]).toString(), i =
|
|
141
|
+
]).toString(), i = g.toString();
|
|
142
142
|
}
|
|
143
|
-
const a = new URLSearchParams([["scalar_url", i.toString()]]), h = B(d, i) ? `${d}?${a.toString()}` : i,
|
|
143
|
+
const a = new URLSearchParams([["scalar_url", i.toString()]]), h = B(d, i) ? `${d}?${a.toString()}` : i, s = await fetch(h, {
|
|
144
144
|
signal: R.signal,
|
|
145
|
-
method:
|
|
145
|
+
method: r.method.toUpperCase(),
|
|
146
146
|
body: C,
|
|
147
147
|
headers: w
|
|
148
148
|
});
|
|
149
|
-
|
|
150
|
-
const
|
|
151
|
-
|
|
149
|
+
S.emit("stop");
|
|
150
|
+
const U = M(
|
|
151
|
+
s.headers,
|
|
152
152
|
B(d, i)
|
|
153
|
-
), D =
|
|
154
|
-
await
|
|
153
|
+
), D = s.headers.get("content-type") ?? "text/plain;charset=UTF-8", A = K(
|
|
154
|
+
await s.arrayBuffer(),
|
|
155
155
|
D
|
|
156
|
-
), F = "getSetCookie" in
|
|
156
|
+
), F = "getSetCookie" in s.headers && typeof s.headers.getSetCookie == "function" ? s.headers.getSetCookie() : [];
|
|
157
157
|
return [
|
|
158
158
|
null,
|
|
159
159
|
{
|
|
160
160
|
timestamp: Date.now(),
|
|
161
161
|
request: o,
|
|
162
162
|
response: {
|
|
163
|
-
...
|
|
164
|
-
headers:
|
|
163
|
+
...s,
|
|
164
|
+
headers: U,
|
|
165
165
|
cookieHeaderKeys: F,
|
|
166
166
|
data: A,
|
|
167
167
|
duration: Date.now() - p,
|
|
168
|
-
method:
|
|
169
|
-
status:
|
|
168
|
+
method: r.method,
|
|
169
|
+
status: s.status,
|
|
170
170
|
path: y
|
|
171
171
|
}
|
|
172
172
|
}
|
|
173
173
|
];
|
|
174
174
|
} catch (a) {
|
|
175
|
-
return
|
|
175
|
+
return S.emit("abort"), [L(a, T.REQUEST_FAILED), null];
|
|
176
176
|
}
|
|
177
177
|
},
|
|
178
178
|
controller: R
|
|
179
179
|
}
|
|
180
180
|
];
|
|
181
181
|
} catch (e) {
|
|
182
|
-
return
|
|
182
|
+
return S.emit("abort"), [L(e), null];
|
|
183
183
|
}
|
|
184
184
|
};
|
|
185
185
|
export {
|