@scalar/api-client 2.1.50 → 2.1.52
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 +33 -0
- package/dist/components/CommandPalette/CommandPaletteCollection.vue.js +1 -1
- package/dist/components/IconSelector.vue.js +2 -2
- 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 +37 -39
- package/dist/layouts/App/create-api-client-app.d.ts +1 -0
- package/dist/layouts/App/create-api-client-app.d.ts.map +1 -1
- package/dist/layouts/Modal/create-api-client-modal.d.ts +2 -0
- package/dist/layouts/Modal/create-api-client-modal.d.ts.map +1 -1
- package/dist/layouts/Web/create-api-client-web.d.ts +1 -0
- package/dist/layouts/Web/create-api-client-web.d.ts.map +1 -1
- package/dist/libs/create-client.d.ts +2 -0
- package/dist/libs/create-client.d.ts.map +1 -1
- package/dist/libs/create-client.js +102 -86
- package/dist/libs/send-request.d.ts +1 -4
- package/dist/libs/send-request.d.ts.map +1 -1
- package/dist/libs/send-request.js +107 -104
- package/dist/libs/string-template.d.ts.map +1 -1
- package/dist/libs/string-template.js +23 -22
- package/dist/style.css +1 -1
- package/dist/views/Request/Request.vue.js +1 -1
- package/dist/views/Request/Request.vue2.js +26 -26
- package/dist/views/Request/RequestSection/RequestTableTooltip.vue.d.ts.map +1 -1
- package/dist/views/Request/RequestSection/RequestTableTooltip.vue.js +27 -27
- package/dist/views/Request/RequestSidebar.vue.d.ts.map +1 -1
- package/dist/views/Request/RequestSidebar.vue.js +1 -1
- package/dist/views/Request/RequestSidebar.vue2.js +2 -2
- package/dist/views/Request/ResponseSection/ResponseBodyRaw.vue.d.ts.map +1 -1
- package/dist/views/Request/ResponseSection/ResponseBodyRaw.vue.js +2 -2
- package/dist/views/Request/ResponseSection/ResponseBodyRaw.vue2.js +35 -15
- package/dist/views/Request/ResponseSection/ResponseEmpty.vue2.js +1 -1
- package/package.json +10 -10
|
@@ -1,190 +1,193 @@
|
|
|
1
1
|
import { ERRORS as B, normalizeError as C } from "./errors.js";
|
|
2
2
|
import { normalizeHeaders as H } from "./normalize-headers.js";
|
|
3
|
-
import { replaceTemplateVariables as
|
|
4
|
-
import { canMethodHaveBody as q, isRelativePath as
|
|
3
|
+
import { replaceTemplateVariables as h } from "./string-template.js";
|
|
4
|
+
import { canMethodHaveBody as q, isRelativePath as A, concatenateUrlAndPath as K, shouldUseProxy as S } from "@scalar/oas-utils/helpers";
|
|
5
5
|
import g from "js-cookie";
|
|
6
|
-
import
|
|
6
|
+
import W from "whatwg-mimetype";
|
|
7
7
|
import { textMediaTypes as _ } from "../views/Request/consts/mediaTypes.js";
|
|
8
|
-
function j(
|
|
9
|
-
const n = new
|
|
10
|
-
return _.includes(n.essence) ? new TextDecoder(n.parameters.get("charset")).decode(
|
|
8
|
+
function j(a, o) {
|
|
9
|
+
const n = new W(o);
|
|
10
|
+
return _.includes(n.essence) ? new TextDecoder(n.parameters.get("charset")).decode(a) : new Blob([a], { type: n.essence });
|
|
11
11
|
}
|
|
12
|
-
function Q(
|
|
12
|
+
function Q(a, o) {
|
|
13
13
|
const n = {};
|
|
14
|
-
return
|
|
15
|
-
const
|
|
16
|
-
e.enabled && (
|
|
14
|
+
return a.parameters.headers.forEach((e) => {
|
|
15
|
+
const m = e.key.trim().toLowerCase();
|
|
16
|
+
e.enabled && (m !== "content-type" || e.value !== "multipart/form-data") && (n[m] = h(e.value, o));
|
|
17
17
|
}), n;
|
|
18
18
|
}
|
|
19
|
-
function V(
|
|
19
|
+
function V(a, o) {
|
|
20
20
|
const n = new URLSearchParams();
|
|
21
|
-
return
|
|
22
|
-
e.enabled && e.value && n.append(e.key,
|
|
21
|
+
return a.parameters.query.forEach((e) => {
|
|
22
|
+
e.enabled && e.value && n.append(e.key, h(e.value, o));
|
|
23
23
|
}), n;
|
|
24
24
|
}
|
|
25
|
-
function
|
|
26
|
-
example:
|
|
27
|
-
env:
|
|
25
|
+
function I({
|
|
26
|
+
example: a,
|
|
27
|
+
env: o,
|
|
28
28
|
globalCookies: n,
|
|
29
29
|
domain: e,
|
|
30
|
-
proxy:
|
|
30
|
+
proxy: m
|
|
31
31
|
}) {
|
|
32
|
-
let
|
|
32
|
+
let f;
|
|
33
33
|
try {
|
|
34
|
-
|
|
34
|
+
f = new URL(m || e).host;
|
|
35
35
|
} catch {
|
|
36
|
-
typeof window < "u" && (
|
|
36
|
+
typeof window < "u" && (f = window.location.host);
|
|
37
37
|
}
|
|
38
|
-
const
|
|
38
|
+
const l = {
|
|
39
39
|
// Must point all cookies to the proxy and let it sort them out
|
|
40
|
-
domain:
|
|
40
|
+
domain: f,
|
|
41
41
|
// Means that the browser sends the cookie with both cross-site and same-site requests.
|
|
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(
|
|
47
|
-
|
|
48
|
-
}), n.forEach((
|
|
45
|
+
}, i = g.get();
|
|
46
|
+
return Object.keys(i).forEach((r) => g.remove(r)), a.parameters.cookies.forEach((r) => {
|
|
47
|
+
r.enabled && g.set(r.key, h(r.value, o));
|
|
48
|
+
}), n.forEach((r) => {
|
|
49
49
|
var R;
|
|
50
|
-
const { name:
|
|
51
|
-
(
|
|
50
|
+
const { name: P, value: s, ...p } = r;
|
|
51
|
+
(p.domain === e || ((R = p.domain) == null ? void 0 : R.startsWith(".")) && e.endsWith(p.domain ?? "")) && g.set(P, s, {
|
|
52
52
|
/** Override the domain with the proxy value */
|
|
53
|
-
domain:
|
|
53
|
+
domain: f,
|
|
54
54
|
// TODO: path cookies probably don't worth with the proxy
|
|
55
|
-
path:
|
|
56
|
-
expires:
|
|
57
|
-
httpOnly:
|
|
58
|
-
secure:
|
|
55
|
+
path: p.path,
|
|
56
|
+
expires: p.expires ? new Date(p.expires) : void 0,
|
|
57
|
+
httpOnly: p.httpOnly,
|
|
58
|
+
secure: p.secure
|
|
59
59
|
});
|
|
60
60
|
}), {
|
|
61
|
-
cookieParams:
|
|
61
|
+
cookieParams: l
|
|
62
62
|
};
|
|
63
63
|
}
|
|
64
|
-
function
|
|
65
|
-
var e,
|
|
66
|
-
if (!q(
|
|
64
|
+
function N(a, o, n) {
|
|
65
|
+
var e, m, f;
|
|
66
|
+
if (!q(a))
|
|
67
67
|
return { body: void 0, contentType: void 0 };
|
|
68
|
-
if (
|
|
69
|
-
const
|
|
70
|
-
return
|
|
71
|
-
!
|
|
72
|
-
}), { body:
|
|
68
|
+
if (o.body.activeBody === "formData" && o.body.formData) {
|
|
69
|
+
const l = o.body.formData.encoding === "form-data" ? "multipart/form-data" : "application/x-www-form-urlencoded", i = o.body.formData.encoding === "form-data" ? new FormData() : new URLSearchParams();
|
|
70
|
+
return o.body.formData.value.forEach((r) => {
|
|
71
|
+
!r.enabled || !r.key || (r.file && i instanceof FormData ? i.append(r.key, r.file, r.file.name) : r.value !== void 0 && i.append(r.key, h(r.value, n)));
|
|
72
|
+
}), { body: i, contentType: l };
|
|
73
73
|
}
|
|
74
|
-
return
|
|
75
|
-
body:
|
|
76
|
-
contentType: (
|
|
77
|
-
} :
|
|
78
|
-
body:
|
|
79
|
-
contentType: (
|
|
74
|
+
return o.body.activeBody === "raw" ? {
|
|
75
|
+
body: h(((e = o.body.raw) == null ? void 0 : e.value) ?? "", n),
|
|
76
|
+
contentType: (m = o.body.raw) == null ? void 0 : m.encoding
|
|
77
|
+
} : o.body.activeBody === "binary" ? {
|
|
78
|
+
body: o.body.binary,
|
|
79
|
+
contentType: (f = o.body.binary) == null ? void 0 : f.type
|
|
80
80
|
} : {
|
|
81
81
|
body: void 0,
|
|
82
82
|
contentType: void 0
|
|
83
83
|
};
|
|
84
84
|
}
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
85
|
+
function Y(a) {
|
|
86
|
+
return a.startsWith("http://") || a.startsWith("https://") ? a : `http://${a}`;
|
|
87
|
+
}
|
|
88
|
+
const ne = ({
|
|
89
|
+
request: a,
|
|
90
|
+
auth: o,
|
|
88
91
|
example: n,
|
|
89
92
|
server: e,
|
|
90
|
-
securitySchemes:
|
|
91
|
-
selectedSecuritySchemeUids:
|
|
92
|
-
proxy:
|
|
93
|
-
status:
|
|
94
|
-
environment:
|
|
95
|
-
globalCookies:
|
|
93
|
+
securitySchemes: m,
|
|
94
|
+
selectedSecuritySchemeUids: f = [],
|
|
95
|
+
proxy: l,
|
|
96
|
+
status: i,
|
|
97
|
+
environment: r,
|
|
98
|
+
globalCookies: P
|
|
96
99
|
}) => {
|
|
97
100
|
try {
|
|
98
|
-
const s =
|
|
101
|
+
const s = r ?? {}, p = new AbortController(), T = n.parameters.path.reduce((u, t) => (t.enabled && (u[t.key] = h(t.value, s)), u), {}), R = h((e == null ? void 0 : e.url) ?? "", s), w = h(a.path, T);
|
|
99
102
|
let d = R || w;
|
|
100
103
|
if (!d) throw B.URL_EMPTY;
|
|
101
|
-
Object.entries((e == null ? void 0 : e.variables) ?? {}).forEach(([
|
|
102
|
-
d =
|
|
104
|
+
Object.entries((e == null ? void 0 : e.variables) ?? {}).forEach(([u, t]) => {
|
|
105
|
+
d = h(d, { [u]: t.default });
|
|
103
106
|
});
|
|
104
|
-
const
|
|
105
|
-
return
|
|
107
|
+
const E = V(n, s), b = Q(n, s), { body: $ } = N(a.method, n, s);
|
|
108
|
+
return I({
|
|
106
109
|
example: n,
|
|
107
110
|
env: s,
|
|
108
|
-
globalCookies:
|
|
111
|
+
globalCookies: P,
|
|
109
112
|
domain: d,
|
|
110
|
-
proxy:
|
|
111
|
-
}),
|
|
112
|
-
const
|
|
113
|
-
if (!(!
|
|
114
|
-
if (y.type === "apiKey" &&
|
|
115
|
-
const
|
|
116
|
-
y.in === "header" && (b[
|
|
113
|
+
proxy: l
|
|
114
|
+
}), f == null || f.forEach((u) => {
|
|
115
|
+
const t = o[u], y = m[u];
|
|
116
|
+
if (!(!t || !y)) {
|
|
117
|
+
if (y.type === "apiKey" && t.type === "apiKey") {
|
|
118
|
+
const c = h(t.value, s);
|
|
119
|
+
y.in === "header" && (b[t.name] = c), y.in === "query" && E.append(t.name, c), y.in === "cookie" && g.set(t.name, c);
|
|
117
120
|
}
|
|
118
|
-
if (y.type === "http" &&
|
|
121
|
+
if (y.type === "http" && t.type === "http")
|
|
119
122
|
if (y.scheme === "basic") {
|
|
120
|
-
const
|
|
121
|
-
b.Authorization = `Basic ${btoa(
|
|
123
|
+
const c = h(t.username, s), v = h(t.password, s), L = `${c}:${v}`;
|
|
124
|
+
b.Authorization = `Basic ${btoa(L)}`;
|
|
122
125
|
} else {
|
|
123
|
-
const
|
|
124
|
-
b.Authorization = `Bearer ${
|
|
126
|
+
const c = h(t.token, s);
|
|
127
|
+
b.Authorization = `Bearer ${c}`;
|
|
125
128
|
}
|
|
126
|
-
y.type === "oauth2" &&
|
|
129
|
+
y.type === "oauth2" && t.type.includes("oauth") && "token" in t && (t.token || console.error("OAuth token was not created"), b.Authorization = `Bearer ${t.token}`);
|
|
127
130
|
}
|
|
128
131
|
}), [
|
|
129
132
|
null,
|
|
130
133
|
{
|
|
131
134
|
sendRequest: async () => {
|
|
132
|
-
|
|
133
|
-
const
|
|
135
|
+
i == null || i.emit("start");
|
|
136
|
+
const u = Date.now();
|
|
134
137
|
try {
|
|
135
|
-
if (d && (!
|
|
136
|
-
const z =
|
|
138
|
+
if (d && (!A(d) || typeof window < "u")) {
|
|
139
|
+
const z = A(d) ? K(window.location.origin, d) : Y(d), k = new URL(z), M = new URL(w, k.origin), D = new URL(k);
|
|
137
140
|
e != null && e.url && (k.pathname === "/" ? D.pathname = w : D.pathname = k.pathname + w), D.search = new URLSearchParams([
|
|
138
141
|
...k.searchParams,
|
|
139
142
|
...M.searchParams,
|
|
140
|
-
...
|
|
143
|
+
...E
|
|
141
144
|
]).toString(), d = D.toString();
|
|
142
145
|
}
|
|
143
|
-
const
|
|
144
|
-
signal:
|
|
145
|
-
method:
|
|
146
|
-
body:
|
|
146
|
+
const t = new URLSearchParams([["scalar_url", d.toString()]]), y = S(l, d) ? `${l}?${t.toString()}` : d, c = await fetch(y, {
|
|
147
|
+
signal: p.signal,
|
|
148
|
+
method: a.method.toUpperCase(),
|
|
149
|
+
body: $,
|
|
147
150
|
headers: b
|
|
148
151
|
});
|
|
149
|
-
|
|
150
|
-
const
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
),
|
|
152
|
+
i == null || i.emit("stop");
|
|
153
|
+
const v = H(
|
|
154
|
+
c.headers,
|
|
155
|
+
S(l, d)
|
|
156
|
+
), L = c.headers.get("content-type") ?? "text/plain;charset=UTF-8", U = await c.arrayBuffer(), F = j(U, L), O = "getSetCookie" in c.headers && typeof c.headers.getSetCookie == "function" ? c.headers.getSetCookie() : [];
|
|
154
157
|
return [
|
|
155
158
|
null,
|
|
156
159
|
{
|
|
157
160
|
timestamp: Date.now(),
|
|
158
161
|
request: n,
|
|
159
162
|
response: {
|
|
160
|
-
...
|
|
161
|
-
headers:
|
|
162
|
-
cookieHeaderKeys:
|
|
163
|
-
data:
|
|
163
|
+
...c,
|
|
164
|
+
headers: v,
|
|
165
|
+
cookieHeaderKeys: O,
|
|
166
|
+
data: F,
|
|
164
167
|
size: U.byteLength,
|
|
165
|
-
duration: Date.now() -
|
|
166
|
-
method:
|
|
167
|
-
status:
|
|
168
|
+
duration: Date.now() - u,
|
|
169
|
+
method: a.method,
|
|
170
|
+
status: c.status,
|
|
168
171
|
path: w
|
|
169
172
|
}
|
|
170
173
|
}
|
|
171
174
|
];
|
|
172
|
-
} catch (
|
|
173
|
-
return
|
|
175
|
+
} catch (t) {
|
|
176
|
+
return i == null || i.emit("abort"), [C(t, B.REQUEST_FAILED), null];
|
|
174
177
|
}
|
|
175
178
|
},
|
|
176
|
-
controller:
|
|
179
|
+
controller: p
|
|
177
180
|
}
|
|
178
181
|
];
|
|
179
182
|
} catch (s) {
|
|
180
|
-
return
|
|
183
|
+
return i == null || i.emit("abort"), [C(s), null];
|
|
181
184
|
}
|
|
182
185
|
};
|
|
183
186
|
export {
|
|
184
|
-
|
|
187
|
+
N as createFetchBody,
|
|
185
188
|
Q as createFetchHeaders,
|
|
186
189
|
V as createFetchQueryParams,
|
|
187
|
-
|
|
190
|
+
ne as createRequestOperation,
|
|
188
191
|
j as decodeBuffer,
|
|
189
|
-
|
|
192
|
+
I as setRequestCookies
|
|
190
193
|
};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"string-template.d.ts","sourceRoot":"","sources":["../../src/libs/string-template.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"string-template.d.ts","sourceRoot":"","sources":["../../src/libs/string-template.ts"],"names":[],"mappings":"AAEA;;;GAGG;AACH,wBAAgB,eAAe,CAAC,IAAI,EAAE,MAAM,EAAE,OAAO,EAAE,MAAM,UAQ5D;AAED;;;;;;GAMG;AACH,wBAAgB,wBAAwB,CACtC,cAAc,EAAE,MAAM,EACtB,OAAO,EAAE,MAAM,UAehB;AAED;;;GAGG;AACH,wBAAgB,cAAc,CAAC,WAAW,EAAE,MAAM,sBAoBjD"}
|
|
@@ -1,30 +1,31 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
1
|
+
import { REGEX as u } from "@scalar/oas-utils/helpers";
|
|
2
|
+
function l(n, o) {
|
|
3
|
+
const t = n.split(".").reduce(
|
|
4
|
+
(e, c) => e == null ? void 0 : e[c],
|
|
5
|
+
o
|
|
5
6
|
);
|
|
6
|
-
return typeof
|
|
7
|
+
return typeof t == "string" ? t : JSON.stringify(t);
|
|
7
8
|
}
|
|
8
|
-
function
|
|
9
|
-
const
|
|
10
|
-
let
|
|
11
|
-
return
|
|
12
|
-
const
|
|
13
|
-
|
|
14
|
-
}),
|
|
9
|
+
function f(n, o) {
|
|
10
|
+
const r = n.match(u.TEMPLATE_VARIABLE) ?? [];
|
|
11
|
+
let t = n;
|
|
12
|
+
return r.forEach((e) => {
|
|
13
|
+
const c = e.startsWith(":") ? e.slice(1) : e.replace(/[{}]/g, "").trim(), s = l(c, o);
|
|
14
|
+
s != null && (t = t.replaceAll(e, s));
|
|
15
|
+
}), t;
|
|
15
16
|
}
|
|
16
|
-
function
|
|
17
|
-
function
|
|
18
|
-
const e = Object.keys(
|
|
19
|
-
return e.forEach((
|
|
20
|
-
const
|
|
21
|
-
typeof
|
|
22
|
-
}),
|
|
17
|
+
function p(n) {
|
|
18
|
+
function o(r, t) {
|
|
19
|
+
const e = Object.keys(r), c = [];
|
|
20
|
+
return e.forEach((s) => {
|
|
21
|
+
const a = t ? `${t}.${s}` : s;
|
|
22
|
+
typeof r[s] == "object" ? c.push(...o(r[s], a)) : c.push([a, String(r[s])]);
|
|
23
|
+
}), c;
|
|
23
24
|
}
|
|
24
|
-
return
|
|
25
|
+
return o(n);
|
|
25
26
|
}
|
|
26
27
|
export {
|
|
27
|
-
|
|
28
|
+
p as flattenEnvVars,
|
|
28
29
|
l as getDotPathValue,
|
|
29
|
-
|
|
30
|
+
f as replaceTemplateVariables
|
|
30
31
|
};
|